File size: 4,074 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 | /*
{
"qid": "021",
"task_type": "ambig",
"has_intended_resolution": true,
"language": "SQLite",
"db": "retails",
"question": "Find customers with high purchase quantities.",
"gold_ambiguity_points": [
{
"id": "A",
"phrase": "high purchase quantities",
"type": "finite",
"ambiguity_type": "semantic_computation",
"interpretations": [
"large total quantities of individual parts",
"large number of line items",
"large number of orders"
],
"intended_interpretation_idx": 0
},
{
"id": "B",
"phrase": "high purchase quantities",
"type": "infinite",
"ambiguity_type": "semantic_value",
"parameter_name": "quantity_threshold",
"parameter_dtype": "int",
"parameter_sample_operators": [
">",
">="
],
"parameter_sample_values": [
2800
],
"intended_parameter_operator": ">=",
"intended_parameter_value": 2800
}
],
"gold_intended_query_id": "GQRY-A.0",
"extra_info": {}
}
*/
----- START OF GOLD QUERY `GQRY-A.0` -----
/*
{
"id": "GQRY-A.0",
"parameter_names": [
"quantity_threshold"
],
"parameter_values": {
"quantity_threshold": 2800
},
"other_exec_results": [],
"required_columns": [
1
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] high purchase quantities": "large total quantities of individual parts",
"[B] high purchase quantities": ":quantity_threshold"
}
}
}
*/
SELECT c.c_custkey, c.c_name, SUM(l.l_quantity) as total_quantity
FROM customer c
JOIN orders o ON c.c_custkey = o.o_custkey
JOIN lineitem l ON o.o_orderkey = l.l_orderkey
GROUP BY c.c_custkey, c.c_name
HAVING SUM(l.l_quantity) >= :quantity_threshold
ORDER BY total_quantity DESC;
/* EXEC RESULT
c_custkey c_name total_quantity
68513 Customer#000068513 3779
114308 Customer#000114308 3612
58421 Customer#000058421 3605
147472 Customer#000147472 3544
48853 Customer#000048853 3535
... TRUNCATED ...
78145 Customer#000078145 2801
2648 Customer#000002648 2800
22985 Customer#000022985 2800
39151 Customer#000039151 2800
102176 Customer#000102176 2800
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.1` -----
/*
{
"id": "GQRY-A.1",
"parameter_names": [
"quantity_threshold"
],
"parameter_values": {
"quantity_threshold": 2800
},
"other_exec_results": [],
"required_columns": [
1
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] high purchase quantities": "large number of line items",
"[B] high purchase quantities": ":quantity_threshold"
}
}
}
*/
SELECT c.c_custkey, c.c_name, COUNT(*) as total_lineitems
FROM customer c
JOIN orders o ON c.c_custkey = o.o_custkey
JOIN lineitem l ON o.o_orderkey = l.l_orderkey
GROUP BY c.c_custkey, c.c_name
HAVING COUNT(*) >= :quantity_threshold
ORDER BY total_lineitems DESC;
/* EXEC RESULT
Empty DataFrame
Columns: [c_custkey, c_name, total_lineitems]
Index: []
*/
----- END OF GOLD QUERY -----
----- START OF GOLD QUERY `GQRY-A.2` -----
/*
{
"id": "GQRY-A.2",
"parameter_names": [
"quantity_threshold"
],
"parameter_values": {
"quantity_threshold": 2800
},
"other_exec_results": [],
"required_columns": [
1
],
"required_sorted": false,
"extra_info": {
"ambiguity_resolution": {
"[A] high purchase quantities": "large number of orders",
"[B] high purchase quantities": ":quantity_threshold"
}
}
}
*/
SELECT c.c_custkey, c.c_name, COUNT(DISTINCT o.o_orderkey) as total_orders
FROM customer c
JOIN orders o ON c.c_custkey = o.o_custkey
GROUP BY c.c_custkey, c.c_name
HAVING COUNT(DISTINCT o.o_orderkey) >= :quantity_threshold
ORDER BY total_orders DESC;
/* EXEC RESULT
Empty DataFrame
Columns: [c_custkey, c_name, total_orders]
Index: []
*/
----- END OF GOLD QUERY ----- |