CoolFace
Apppublic

Kalletlamadhav/sql_optimized_env_new

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
mgnrega_implicit_cast.py30 linesDownload Raw Back to hard
1from tasks.base_task import BaseTask2from tasks._schema_loader import load_schema3 4TASK = BaseTask(5    task_id="mgnrega_implicit_cast",6    goal=(7        "An MGNREGA payment officer queries workers with wage rate above minimum. "8        "The WHERE clause compares wage_rate (DECIMAL column) to a string '250', "9        "causing implicit type cast and disabling index usage. Remove the quotes."10    ),11    slow_query="""12        SELECT worker_id, worker_name, wage_rate, state_code13        FROM mgnrega_workers14        WHERE wage_rate > '250'15        ORDER BY wage_rate DESC16    """,17    expected_pattern="IMPLICIT_CAST",18    tables=["mgnrega_workers"],19    schema_ddl=load_schema("mgnrega_schema.sql"),20    difficulty="hard",21    curriculum_level=3,22    hint="wage_rate is a DECIMAL column. Comparing it to the string '250' (with quotes) forces a type cast. Remove the quotes: WHERE wage_rate > 250",23    reference_fix="""24        SELECT worker_id, worker_name, wage_rate, state_code25        FROM mgnrega_workers26        WHERE wage_rate > 25027        ORDER BY wage_rate DESC28    """,29)30