File size: 4,575 Bytes
02edc38 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | /*
{
"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 ----- |