| /* | |
| { | |
| "qid": "024", | |
| "task_type": "ambig", | |
| "has_intended_resolution": true, | |
| "language": "SQLite", | |
| "db": "retails", | |
| "question": "Show large orders placed in February 1996.", | |
| "gold_ambiguity_points": [ | |
| { | |
| "id": "A", | |
| "phrase": "large orders", | |
| "type": "finite", | |
| "ambiguity_type": "semantic_computation", | |
| "interpretations": [ | |
| "orders with high total price", | |
| "orders with large number of line items", | |
| "orders with large total quantity of parts" | |
| ], | |
| "intended_interpretation_idx": 0 | |
| }, | |
| { | |
| "id": "B", | |
| "phrase": "large orders", | |
| "type": "infinite", | |
| "ambiguity_type": "semantic_value", | |
| "parameter_name": "large_threshold", | |
| "parameter_dtype": "int", | |
| "parameter_sample_operators": [ | |
| ">", | |
| ">=" | |
| ], | |
| "parameter_sample_values": [ | |
| 250 | |
| ], | |
| "intended_parameter_operator": ">", | |
| "intended_parameter_value": 250 | |
| } | |
| ], | |
| "gold_intended_query_id": "GQRY-A.0", | |
| "extra_info": {} | |
| } | |
| */ | |
| ----- START OF GOLD QUERY `GQRY-A.0` ----- | |
| /* | |
| { | |
| "id": "GQRY-A.0", | |
| "parameter_names": [ | |
| "large_threshold" | |
| ], | |
| "parameter_values": { | |
| "large_threshold": 250 | |
| }, | |
| "other_exec_results": [], | |
| "required_columns": [ | |
| 0 | |
| ], | |
| "required_sorted": false, | |
| "extra_info": { | |
| "ambiguity_resolution": { | |
| "[A] large orders": "orders with high total price", | |
| "[B] large orders": ":large_threshold" | |
| } | |
| } | |
| } | |
| */ | |
| WITH feb_orders AS ( | |
| SELECT o_orderkey, o_orderdate, o_totalprice | |
| FROM orders | |
| WHERE o_orderdate >= '1996-02-01' | |
| AND o_orderdate < '1996-03-01' | |
| ) | |
| SELECT o_orderkey, o_orderdate, o_totalprice | |
| FROM feb_orders | |
| WHERE o_totalprice > :large_threshold | |
| ORDER BY o_totalprice DESC; | |
| /* EXEC RESULT | |
| o_orderkey o_orderdate o_totalprice | |
| 504642 1996-02-28 496726.35 | |
| 3899781 1996-02-08 484817.17 | |
| 3093796 1996-02-02 470846.96 | |
| 2223461 1996-02-16 468971.22 | |
| 64900 1996-02-27 457183.27 | |
| ... TRUNCATED ... | |
| 3599271 1996-02-26 1077.86 | |
| 3753634 1996-02-24 1064.13 | |
| 3080519 1996-02-07 977.02 | |
| 1130592 1996-02-25 969.48 | |
| 4659585 1996-02-04 930.11 | |
| */ | |
| ----- END OF GOLD QUERY ----- | |
| ----- START OF GOLD QUERY `GQRY-A.1` ----- | |
| /* | |
| { | |
| "id": "GQRY-A.1", | |
| "parameter_names": [ | |
| "large_threshold" | |
| ], | |
| "parameter_values": { | |
| "large_threshold": 250 | |
| }, | |
| "other_exec_results": [], | |
| "required_columns": [ | |
| 0 | |
| ], | |
| "required_sorted": false, | |
| "extra_info": { | |
| "ambiguity_resolution": { | |
| "[A] large orders": "orders with large number of line items", | |
| "[B] large orders": ":large_threshold" | |
| } | |
| } | |
| } | |
| */ | |
| WITH feb_orders_lineitem_count AS ( | |
| SELECT o.o_orderkey, o_orderdate, COUNT(*) AS num_lineitems | |
| FROM orders o | |
| JOIN lineitem l ON o.o_orderkey = l.l_orderkey | |
| WHERE o.o_orderdate >= '1996-02-01' | |
| AND o.o_orderdate < '1996-03-01' | |
| GROUP BY o.o_orderkey, o.o_orderdate | |
| ) | |
| SELECT o_orderkey, o_orderdate, num_lineitems | |
| FROM feb_orders_lineitem_count | |
| WHERE num_lineitems > :large_threshold | |
| ORDER BY num_lineitems DESC; | |
| /* EXEC RESULT | |
| Empty DataFrame | |
| Columns: [o_orderkey, o_orderdate, num_lineitems] | |
| Index: [] | |
| */ | |
| ----- END OF GOLD QUERY ----- | |
| ----- START OF GOLD QUERY `GQRY-A.2` ----- | |
| /* | |
| { | |
| "id": "GQRY-A.2", | |
| "parameter_names": [ | |
| "large_threshold" | |
| ], | |
| "parameter_values": { | |
| "large_threshold": 250 | |
| }, | |
| "other_exec_results": [], | |
| "required_columns": [ | |
| 0 | |
| ], | |
| "required_sorted": false, | |
| "extra_info": { | |
| "ambiguity_resolution": { | |
| "[A] large orders": "orders with large total quantity of parts", | |
| "[B] large orders": ":large_threshold" | |
| } | |
| } | |
| } | |
| */ | |
| WITH feb_orders_quantity AS ( | |
| SELECT o.o_orderkey, o.o_orderdate, SUM(l.l_quantity) AS total_quantity | |
| FROM orders o | |
| JOIN lineitem l ON o.o_orderkey = l.l_orderkey | |
| WHERE o.o_orderdate >= '1996-02-01' | |
| AND o.o_orderdate < '1996-03-01' | |
| GROUP BY o.o_orderkey, o.o_orderdate | |
| ) | |
| SELECT o_orderkey, o_orderdate, total_quantity | |
| FROM feb_orders_quantity | |
| WHERE total_quantity > :large_threshold | |
| ORDER BY total_quantity DESC; | |
| /* EXEC RESULT | |
| o_orderkey o_orderdate total_quantity | |
| 5494980 1996-02-27 304 | |
| 304644 1996-02-25 298 | |
| 1061504 1996-02-16 298 | |
| 2223461 1996-02-16 297 | |
| 3093796 1996-02-02 297 | |
| ... TRUNCATED ... | |
| 3193316 1996-02-10 252 | |
| 5412101 1996-02-04 252 | |
| 1586627 1996-02-02 251 | |
| 2658657 1996-02-15 251 | |
| 4993253 1996-02-09 251 | |
| */ | |
| ----- END OF GOLD QUERY ----- |