vitess.io/vitess@v0.16.2/go/vt/vtgate/planbuilder/testdata/tpch_cases.json (about) 1 [ 2 { 3 "comment": "TPC-H query 1", 4 "query": "select l_returnflag, l_linestatus, sum(l_quantity) as sum_qty, sum(l_extendedprice) as sum_base_price, sum(l_extendedprice * (1 - l_discount)) as sum_disc_price, sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge, avg(l_quantity) as avg_qty, avg(l_extendedprice) as avg_price, avg(l_discount) as avg_disc, count(*) as count_order from lineitem where l_shipdate <= '1998-12-01' - interval '108' day group by l_returnflag, l_linestatus order by l_returnflag, l_linestatus", 5 "v3-plan": "VT12001: unsupported: in scatter query: complex aggregate expression", 6 "gen4-plan": "VT12001: unsupported: in scatter query: aggregation function 'avg'" 7 }, 8 { 9 "comment": "TPC-H query 2", 10 "query": "select s_acctbal, s_name, n_name, p_partkey, p_mfgr, s_address, s_phone, s_comment from part, supplier, partsupp, nation, region where p_partkey = ps_partkey and s_suppkey = ps_suppkey and p_size = 15 and p_type like '%BRASS' and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = 'EUROPE' and ps_supplycost = ( select min(ps_supplycost) from partsupp, supplier, nation, region where p_partkey = ps_partkey and s_suppkey = ps_suppkey and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = 'EUROPE' ) order by s_acctbal desc, n_name, s_name, p_partkey limit 10", 11 "v3-plan": "VT03019: symbol p_partkey not found", 12 "gen4-plan": "VT12001: unsupported: cross-shard correlated subquery" 13 }, 14 { 15 "comment": "TPC-H query 3", 16 "query": "select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date('1995-03-15') and l_shipdate > date('1995-03-15') group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate limit 10", 17 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 18 "gen4-plan": { 19 "QueryType": "SELECT", 20 "Original": "select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date('1995-03-15') and l_shipdate > date('1995-03-15') group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate limit 10", 21 "Instructions": { 22 "OperatorType": "Limit", 23 "Count": "INT64(10)", 24 "Inputs": [ 25 { 26 "OperatorType": "Sort", 27 "Variant": "Memory", 28 "OrderBy": "1 DESC, (2|5) ASC", 29 "ResultColumns": 4, 30 "Inputs": [ 31 { 32 "OperatorType": "Aggregate", 33 "Variant": "Ordered", 34 "Aggregates": "sum(1) AS revenue", 35 "GroupBy": "(0|6), (2|5), (3|4)", 36 "Inputs": [ 37 { 38 "OperatorType": "Projection", 39 "Expressions": [ 40 "[COLUMN 0] as l_orderkey", 41 "([COLUMN 6] * COALESCE([COLUMN 7], INT64(1))) * COALESCE([COLUMN 8], INT64(1)) as revenue", 42 "[COLUMN 1] as o_orderdate", 43 "[COLUMN 2] as o_shippriority", 44 "[COLUMN 5]", 45 "[COLUMN 4]", 46 "[COLUMN 3]" 47 ], 48 "Inputs": [ 49 { 50 "OperatorType": "Sort", 51 "Variant": "Memory", 52 "OrderBy": "(0|3) ASC, (1|4) ASC, (2|5) ASC", 53 "Inputs": [ 54 { 55 "OperatorType": "Join", 56 "Variant": "Join", 57 "JoinColumnIndexes": "L:0,R:0,R:1,L:2,R:2,R:3,L:1,R:4,R:5", 58 "JoinVars": { 59 "l_orderkey": 0 60 }, 61 "TableName": "lineitem_orders_customer", 62 "Inputs": [ 63 { 64 "OperatorType": "Route", 65 "Variant": "Scatter", 66 "Keyspace": { 67 "Name": "main", 68 "Sharded": true 69 }, 70 "FieldQuery": "select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, weight_string(l_orderkey) from lineitem where 1 != 1 group by l_orderkey, weight_string(l_orderkey)", 71 "Query": "select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, weight_string(l_orderkey) from lineitem where l_shipdate > date('1995-03-15') group by l_orderkey, weight_string(l_orderkey)", 72 "Table": "lineitem" 73 }, 74 { 75 "OperatorType": "Join", 76 "Variant": "Join", 77 "JoinColumnIndexes": "L:3,L:5,L:4,L:6,L:1,R:1", 78 "JoinVars": { 79 "o_custkey": 0 80 }, 81 "TableName": "orders_customer", 82 "Inputs": [ 83 { 84 "OperatorType": "Route", 85 "Variant": "EqualUnique", 86 "Keyspace": { 87 "Name": "main", 88 "Sharded": true 89 }, 90 "FieldQuery": "select o_custkey, count(*), weight_string(o_custkey), o_orderdate, weight_string(o_orderdate), o_shippriority, weight_string(o_shippriority) from orders where 1 != 1 group by o_custkey, weight_string(o_custkey), o_orderdate, weight_string(o_orderdate), o_shippriority, weight_string(o_shippriority)", 91 "Query": "select o_custkey, count(*), weight_string(o_custkey), o_orderdate, weight_string(o_orderdate), o_shippriority, weight_string(o_shippriority) from orders where o_orderdate < date('1995-03-15') and o_orderkey = :l_orderkey group by o_custkey, weight_string(o_custkey), o_orderdate, weight_string(o_orderdate), o_shippriority, weight_string(o_shippriority)", 92 "Table": "orders", 93 "Values": [ 94 ":l_orderkey" 95 ], 96 "Vindex": "hash" 97 }, 98 { 99 "OperatorType": "Route", 100 "Variant": "EqualUnique", 101 "Keyspace": { 102 "Name": "main", 103 "Sharded": true 104 }, 105 "FieldQuery": "select 1, count(*) from customer where 1 != 1 group by 1", 106 "Query": "select 1, count(*) from customer where c_mktsegment = 'BUILDING' and c_custkey = :o_custkey group by 1", 107 "Table": "customer", 108 "Values": [ 109 ":o_custkey" 110 ], 111 "Vindex": "hash" 112 } 113 ] 114 } 115 ] 116 } 117 ] 118 } 119 ] 120 } 121 ] 122 } 123 ] 124 } 125 ] 126 }, 127 "TablesUsed": [ 128 "main.customer", 129 "main.lineitem", 130 "main.orders" 131 ] 132 } 133 }, 134 { 135 "comment": "TPC-H query 4", 136 "query": "select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date('1993-07-01') and o_orderdate < date('1993-07-01') + interval '3' month and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority", 137 "v3-plan": "VT03019: symbol o_orderkey not found", 138 "gen4-plan": { 139 "QueryType": "SELECT", 140 "Original": "select o_orderpriority, count(*) as order_count from orders where o_orderdate >= date('1993-07-01') and o_orderdate < date('1993-07-01') + interval '3' month and exists ( select * from lineitem where l_orderkey = o_orderkey and l_commitdate < l_receiptdate ) group by o_orderpriority order by o_orderpriority", 141 "Instructions": { 142 "OperatorType": "Aggregate", 143 "Variant": "Ordered", 144 "Aggregates": "sum_count_star(1) AS order_count", 145 "GroupBy": "(0|2)", 146 "ResultColumns": 2, 147 "Inputs": [ 148 { 149 "OperatorType": "Projection", 150 "Expressions": [ 151 "[COLUMN 1] as o_orderpriority", 152 "[COLUMN 2] as order_count", 153 "[COLUMN 3]" 154 ], 155 "Inputs": [ 156 { 157 "OperatorType": "SemiJoin", 158 "JoinVars": { 159 "o_orderkey": 0 160 }, 161 "TableName": "orders_lineitem", 162 "Inputs": [ 163 { 164 "OperatorType": "Route", 165 "Variant": "Scatter", 166 "Keyspace": { 167 "Name": "main", 168 "Sharded": true 169 }, 170 "FieldQuery": "select o_orderkey, o_orderpriority, count(*) as order_count, weight_string(o_orderpriority), weight_string(o_orderkey) from orders where 1 != 1 group by o_orderpriority, weight_string(o_orderpriority), o_orderkey, weight_string(o_orderkey)", 171 "OrderBy": "(1|3) ASC", 172 "Query": "select o_orderkey, o_orderpriority, count(*) as order_count, weight_string(o_orderpriority), weight_string(o_orderkey) from orders where o_orderdate >= date('1993-07-01') and o_orderdate < date('1993-07-01') + interval '3' month group by o_orderpriority, weight_string(o_orderpriority), o_orderkey, weight_string(o_orderkey) order by o_orderpriority asc", 173 "Table": "orders" 174 }, 175 { 176 "OperatorType": "VindexLookup", 177 "Variant": "EqualUnique", 178 "Keyspace": { 179 "Name": "main", 180 "Sharded": true 181 }, 182 "Values": [ 183 ":o_orderkey" 184 ], 185 "Vindex": "lineitem_map", 186 "Inputs": [ 187 { 188 "OperatorType": "Route", 189 "Variant": "IN", 190 "Keyspace": { 191 "Name": "main", 192 "Sharded": true 193 }, 194 "FieldQuery": "select l_orderkey, l_linenumber from lineitem_map where 1 != 1", 195 "Query": "select l_orderkey, l_linenumber from lineitem_map where l_orderkey in ::__vals", 196 "Table": "lineitem_map", 197 "Values": [ 198 ":l_orderkey" 199 ], 200 "Vindex": "md5" 201 }, 202 { 203 "OperatorType": "Route", 204 "Variant": "ByDestination", 205 "Keyspace": { 206 "Name": "main", 207 "Sharded": true 208 }, 209 "FieldQuery": "select 1 from lineitem where 1 != 1", 210 "Query": "select 1 from lineitem where l_commitdate < l_receiptdate and l_orderkey = :o_orderkey", 211 "Table": "lineitem" 212 } 213 ] 214 } 215 ] 216 } 217 ] 218 } 219 ] 220 }, 221 "TablesUsed": [ 222 "main.lineitem", 223 "main.orders" 224 ] 225 } 226 }, 227 { 228 "comment": "TPC-H query 5 - Gen4 produces plan but the plan output is flaky", 229 "query": "select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey and l_suppkey = s_suppkey and c_nationkey = s_nationkey and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = 'ASIA' and o_orderdate >= date('1994-01-01') and o_orderdate < date('1994-01-01') + interval '1' year group by n_name order by revenue desc", 230 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 231 "gen4-plan": { 232 "QueryType": "SELECT", 233 "Original": "select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey and l_suppkey = s_suppkey and c_nationkey = s_nationkey and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = 'ASIA' and o_orderdate >= date('1994-01-01') and o_orderdate < date('1994-01-01') + interval '1' year group by n_name order by revenue desc", 234 "Instructions": { 235 "OperatorType": "Sort", 236 "Variant": "Memory", 237 "OrderBy": "1 DESC", 238 "ResultColumns": 2, 239 "Inputs": [ 240 { 241 "OperatorType": "Aggregate", 242 "Variant": "Ordered", 243 "Aggregates": "sum(1) AS revenue", 244 "GroupBy": "(0|2)", 245 "Inputs": [ 246 { 247 "OperatorType": "Projection", 248 "Expressions": [ 249 "[COLUMN 0] as n_name", 250 "(((([COLUMN 2] * COALESCE([COLUMN 3], INT64(1))) * COALESCE([COLUMN 4], INT64(1))) * COALESCE([COLUMN 5], INT64(1))) * COALESCE([COLUMN 6], INT64(1))) * COALESCE([COLUMN 7], INT64(1)) as revenue", 251 "[COLUMN 1]" 252 ], 253 "Inputs": [ 254 { 255 "OperatorType": "Sort", 256 "Variant": "Memory", 257 "OrderBy": "(0|1) ASC", 258 "Inputs": [ 259 { 260 "OperatorType": "Join", 261 "Variant": "Join", 262 "JoinColumnIndexes": "R:0,R:1,L:3,L:4,L:5,L:6,R:2,R:3", 263 "JoinVars": { 264 "s_nationkey": 0 265 }, 266 "TableName": "orders_customer_lineitem_supplier_nation_region", 267 "Inputs": [ 268 { 269 "OperatorType": "Join", 270 "Variant": "Join", 271 "JoinColumnIndexes": "R:0,R:1,R:2,L:6,L:7,R:3,R:4", 272 "JoinVars": { 273 "c_nationkey": 1, 274 "o_orderkey": 0 275 }, 276 "TableName": "orders_customer_lineitem_supplier", 277 "Inputs": [ 278 { 279 "OperatorType": "Join", 280 "Variant": "Join", 281 "JoinColumnIndexes": "L:1,R:0,L:1,R:0,L:4,R:2,L:2,R:1", 282 "JoinVars": { 283 "o_custkey": 0 284 }, 285 "TableName": "orders_customer", 286 "Inputs": [ 287 { 288 "OperatorType": "Route", 289 "Variant": "Scatter", 290 "Keyspace": { 291 "Name": "main", 292 "Sharded": true 293 }, 294 "FieldQuery": "select o_custkey, o_orderkey, count(*), weight_string(o_custkey), weight_string(o_orderkey) from orders where 1 != 1 group by o_custkey, weight_string(o_custkey), o_orderkey, weight_string(o_orderkey)", 295 "Query": "select o_custkey, o_orderkey, count(*), weight_string(o_custkey), weight_string(o_orderkey) from orders where o_orderdate >= date('1994-01-01') and o_orderdate < date('1994-01-01') + interval '1' year group by o_custkey, weight_string(o_custkey), o_orderkey, weight_string(o_orderkey)", 296 "Table": "orders" 297 }, 298 { 299 "OperatorType": "Route", 300 "Variant": "EqualUnique", 301 "Keyspace": { 302 "Name": "main", 303 "Sharded": true 304 }, 305 "FieldQuery": "select c_nationkey, count(*), weight_string(c_nationkey) from customer where 1 != 1 group by c_nationkey, weight_string(c_nationkey)", 306 "Query": "select c_nationkey, count(*), weight_string(c_nationkey) from customer where c_custkey = :o_custkey group by c_nationkey, weight_string(c_nationkey)", 307 "Table": "customer", 308 "Values": [ 309 ":o_custkey" 310 ], 311 "Vindex": "hash" 312 } 313 ] 314 }, 315 { 316 "OperatorType": "Join", 317 "Variant": "Join", 318 "JoinColumnIndexes": "R:0,R:0,R:2,L:1,R:1", 319 "JoinVars": { 320 "l_suppkey": 0 321 }, 322 "TableName": "lineitem_supplier", 323 "Inputs": [ 324 { 325 "OperatorType": "VindexLookup", 326 "Variant": "EqualUnique", 327 "Keyspace": { 328 "Name": "main", 329 "Sharded": true 330 }, 331 "Values": [ 332 ":o_orderkey" 333 ], 334 "Vindex": "lineitem_map", 335 "Inputs": [ 336 { 337 "OperatorType": "Route", 338 "Variant": "IN", 339 "Keyspace": { 340 "Name": "main", 341 "Sharded": true 342 }, 343 "FieldQuery": "select l_orderkey, l_linenumber from lineitem_map where 1 != 1", 344 "Query": "select l_orderkey, l_linenumber from lineitem_map where l_orderkey in ::__vals", 345 "Table": "lineitem_map", 346 "Values": [ 347 ":l_orderkey" 348 ], 349 "Vindex": "md5" 350 }, 351 { 352 "OperatorType": "Route", 353 "Variant": "ByDestination", 354 "Keyspace": { 355 "Name": "main", 356 "Sharded": true 357 }, 358 "FieldQuery": "select l_suppkey, sum(l_extendedprice * (1 - l_discount)) as revenue, weight_string(l_suppkey) from lineitem where 1 != 1 group by l_suppkey, weight_string(l_suppkey)", 359 "Query": "select l_suppkey, sum(l_extendedprice * (1 - l_discount)) as revenue, weight_string(l_suppkey) from lineitem where l_orderkey = :o_orderkey group by l_suppkey, weight_string(l_suppkey)", 360 "Table": "lineitem" 361 } 362 ] 363 }, 364 { 365 "OperatorType": "Route", 366 "Variant": "EqualUnique", 367 "Keyspace": { 368 "Name": "main", 369 "Sharded": true 370 }, 371 "FieldQuery": "select s_nationkey, count(*), weight_string(s_nationkey) from supplier where 1 != 1 group by s_nationkey, weight_string(s_nationkey)", 372 "Query": "select s_nationkey, count(*), weight_string(s_nationkey) from supplier where s_suppkey = :l_suppkey and s_nationkey = :c_nationkey group by s_nationkey, weight_string(s_nationkey)", 373 "Table": "supplier", 374 "Values": [ 375 ":l_suppkey" 376 ], 377 "Vindex": "hash" 378 } 379 ] 380 } 381 ] 382 }, 383 { 384 "OperatorType": "Join", 385 "Variant": "Join", 386 "JoinColumnIndexes": "L:3,L:4,L:1,R:1", 387 "JoinVars": { 388 "n_regionkey": 0 389 }, 390 "TableName": "nation_region", 391 "Inputs": [ 392 { 393 "OperatorType": "Route", 394 "Variant": "EqualUnique", 395 "Keyspace": { 396 "Name": "main", 397 "Sharded": true 398 }, 399 "FieldQuery": "select n_regionkey, count(*), weight_string(n_regionkey), n_name, weight_string(n_name) from nation where 1 != 1 group by n_regionkey, weight_string(n_regionkey), n_name, weight_string(n_name)", 400 "Query": "select n_regionkey, count(*), weight_string(n_regionkey), n_name, weight_string(n_name) from nation where n_nationkey = :s_nationkey group by n_regionkey, weight_string(n_regionkey), n_name, weight_string(n_name)", 401 "Table": "nation", 402 "Values": [ 403 ":s_nationkey" 404 ], 405 "Vindex": "hash" 406 }, 407 { 408 "OperatorType": "Route", 409 "Variant": "EqualUnique", 410 "Keyspace": { 411 "Name": "main", 412 "Sharded": true 413 }, 414 "FieldQuery": "select 1, count(*) from region where 1 != 1 group by 1", 415 "Query": "select 1, count(*) from region where r_name = 'ASIA' and r_regionkey = :n_regionkey group by 1", 416 "Table": "region", 417 "Values": [ 418 ":n_regionkey" 419 ], 420 "Vindex": "hash" 421 } 422 ] 423 } 424 ] 425 } 426 ] 427 } 428 ] 429 } 430 ] 431 } 432 ] 433 }, 434 "TablesUsed": [ 435 "main.customer", 436 "main.lineitem", 437 "main.nation", 438 "main.orders", 439 "main.region", 440 "main.supplier" 441 ] 442 } 443 }, 444 { 445 "comment": "TPC-H query 6", 446 "query": "select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= date('1994-01-01') and l_shipdate < date('1994-01-01') + interval '1' year and l_discount between 0.06 - 0.01 and 0.06 + 0.01 and l_quantity < 24", 447 "v3-plan": { 448 "QueryType": "SELECT", 449 "Original": "select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= date('1994-01-01') and l_shipdate < date('1994-01-01') + interval '1' year and l_discount between 0.06 - 0.01 and 0.06 + 0.01 and l_quantity < 24", 450 "Instructions": { 451 "OperatorType": "Aggregate", 452 "Variant": "Scalar", 453 "Aggregates": "sum(0)", 454 "Inputs": [ 455 { 456 "OperatorType": "Route", 457 "Variant": "Scatter", 458 "Keyspace": { 459 "Name": "main", 460 "Sharded": true 461 }, 462 "FieldQuery": "select sum(l_extendedprice * l_discount) as revenue from lineitem where 1 != 1", 463 "Query": "select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= date('1994-01-01') and l_shipdate < date('1994-01-01') + interval '1' year and l_discount between 0.06 - 0.01 and 0.06 + 0.01 and l_quantity < 24", 464 "Table": "lineitem" 465 } 466 ] 467 } 468 }, 469 "gen4-plan": { 470 "QueryType": "SELECT", 471 "Original": "select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= date('1994-01-01') and l_shipdate < date('1994-01-01') + interval '1' year and l_discount between 0.06 - 0.01 and 0.06 + 0.01 and l_quantity < 24", 472 "Instructions": { 473 "OperatorType": "Aggregate", 474 "Variant": "Scalar", 475 "Aggregates": "sum(0) AS revenue", 476 "Inputs": [ 477 { 478 "OperatorType": "Route", 479 "Variant": "Scatter", 480 "Keyspace": { 481 "Name": "main", 482 "Sharded": true 483 }, 484 "FieldQuery": "select sum(l_extendedprice * l_discount) as revenue from lineitem where 1 != 1", 485 "Query": "select sum(l_extendedprice * l_discount) as revenue from lineitem where l_shipdate >= date('1994-01-01') and l_shipdate < date('1994-01-01') + interval '1' year and l_discount between 0.06 - 0.01 and 0.06 + 0.01 and l_quantity < 24", 486 "Table": "lineitem" 487 } 488 ] 489 }, 490 "TablesUsed": [ 491 "main.lineitem" 492 ] 493 } 494 }, 495 { 496 "comment": "TPC-H query 7", 497 "query": "select supp_nation, cust_nation, l_year, sum(volume) as revenue from (select n1.n_name as supp_nation, n2.n_name as cust_nation, extract(year from l_shipdate) as l_year, l_extendedprice * (1 - l_discount) as volume from supplier, lineitem, orders, customer, nation n1, nation n2 where s_suppkey = l_suppkey and o_orderkey = l_orderkey and c_custkey = o_custkey and s_nationkey = n1.n_nationkey and c_nationkey = n2.n_nationkey and ((n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY') or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE')) and l_shipdate between date('1995-01-01') and date('1996-12-31')) as shipping group by supp_nation, cust_nation, l_year order by supp_nation, cust_nation, l_year", 498 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 499 "gen4-plan": { 500 "QueryType": "SELECT", 501 "Original": "select supp_nation, cust_nation, l_year, sum(volume) as revenue from (select n1.n_name as supp_nation, n2.n_name as cust_nation, extract(year from l_shipdate) as l_year, l_extendedprice * (1 - l_discount) as volume from supplier, lineitem, orders, customer, nation n1, nation n2 where s_suppkey = l_suppkey and o_orderkey = l_orderkey and c_custkey = o_custkey and s_nationkey = n1.n_nationkey and c_nationkey = n2.n_nationkey and ((n1.n_name = 'FRANCE' and n2.n_name = 'GERMANY') or (n1.n_name = 'GERMANY' and n2.n_name = 'FRANCE')) and l_shipdate between date('1995-01-01') and date('1996-12-31')) as shipping group by supp_nation, cust_nation, l_year order by supp_nation, cust_nation, l_year", 502 "Instructions": { 503 "OperatorType": "Aggregate", 504 "Variant": "Ordered", 505 "Aggregates": "sum(3) AS revenue", 506 "GroupBy": "(0|6), (1|5), (2|4)", 507 "ResultColumns": 4, 508 "Inputs": [ 509 { 510 "OperatorType": "Projection", 511 "Expressions": [ 512 "[COLUMN 4] as supp_nation", 513 "[COLUMN 5] as cust_nation", 514 "[COLUMN 6] as l_year", 515 "(((([COLUMN 10] * COALESCE([COLUMN 11], INT64(1))) * COALESCE([COLUMN 12], INT64(1))) * COALESCE([COLUMN 13], INT64(1))) * COALESCE([COLUMN 14], INT64(1))) * COALESCE([COLUMN 15], INT64(1)) as revenue", 516 "[COLUMN 9]", 517 "[COLUMN 8]", 518 "[COLUMN 7]" 519 ], 520 "Inputs": [ 521 { 522 "OperatorType": "Sort", 523 "Variant": "Memory", 524 "OrderBy": "(0|16) ASC, (1|17) ASC, (2|18) ASC", 525 "Inputs": [ 526 { 527 "OperatorType": "Join", 528 "Variant": "Join", 529 "JoinColumnIndexes": "L:2,R:0,L:3,L:4,L:8,R:1,L:9,L:13,R:2,L:14,L:15,L:16,L:17,L:18,R:3,R:4,L:19,R:5,L:20", 530 "JoinVars": { 531 "n1_n_name": 1, 532 "o_custkey": 0 533 }, 534 "TableName": "lineitem_orders_supplier_nation_customer_nation", 535 "Inputs": [ 536 { 537 "OperatorType": "Join", 538 "Variant": "Join", 539 "JoinColumnIndexes": "L:1,R:0,R:1,L:2,L:3,L:5,R:2,R:3,R:4,L:6,L:8,R:5,R:6,R:7,L:9,L:10,L:11,R:8,R:9,R:10,L:12", 540 "JoinVars": { 541 "l_suppkey": 0 542 }, 543 "TableName": "lineitem_orders_supplier_nation", 544 "Inputs": [ 545 { 546 "OperatorType": "Join", 547 "Variant": "Join", 548 "JoinColumnIndexes": "L:1,R:0,L:2,L:3,L:1,R:0,L:2,L:6,R:2,L:7,L:4,R:1,L:8", 549 "JoinVars": { 550 "l_orderkey": 0 551 }, 552 "TableName": "lineitem_orders", 553 "Inputs": [ 554 { 555 "OperatorType": "Route", 556 "Variant": "Scatter", 557 "Keyspace": { 558 "Name": "main", 559 "Sharded": true 560 }, 561 "FieldQuery": "select l_orderkey, l_suppkey, extract(year from l_shipdate) as l_year, l_extendedprice * (1 - l_discount) as volume, sum(volume) as revenue, weight_string(l_orderkey), weight_string(l_suppkey), weight_string(extract(year from l_shipdate)), weight_string(extract(year from l_shipdate)) from lineitem where 1 != 1 group by l_orderkey, weight_string(l_orderkey), l_suppkey, weight_string(l_suppkey), l_year, weight_string(l_year)", 562 "Query": "select l_orderkey, l_suppkey, extract(year from l_shipdate) as l_year, l_extendedprice * (1 - l_discount) as volume, sum(volume) as revenue, weight_string(l_orderkey), weight_string(l_suppkey), weight_string(extract(year from l_shipdate)), weight_string(extract(year from l_shipdate)) from lineitem where l_shipdate between date('1995-01-01') and date('1996-12-31') group by l_orderkey, weight_string(l_orderkey), l_suppkey, weight_string(l_suppkey), l_year, weight_string(l_year)", 563 "Table": "lineitem" 564 }, 565 { 566 "OperatorType": "Route", 567 "Variant": "EqualUnique", 568 "Keyspace": { 569 "Name": "main", 570 "Sharded": true 571 }, 572 "FieldQuery": "select o_custkey, count(*), weight_string(o_custkey) from orders where 1 != 1 group by o_custkey, weight_string(o_custkey)", 573 "Query": "select o_custkey, count(*), weight_string(o_custkey) from orders where o_orderkey = :l_orderkey group by o_custkey, weight_string(o_custkey)", 574 "Table": "orders", 575 "Values": [ 576 ":l_orderkey" 577 ], 578 "Vindex": "hash" 579 } 580 ] 581 }, 582 { 583 "OperatorType": "Join", 584 "Variant": "Join", 585 "JoinColumnIndexes": "R:0,R:1,R:0,R:0,R:1,R:3,R:3,R:4,L:1,R:2,R:5", 586 "JoinVars": { 587 "s_nationkey": 0 588 }, 589 "TableName": "supplier_nation", 590 "Inputs": [ 591 { 592 "OperatorType": "Route", 593 "Variant": "EqualUnique", 594 "Keyspace": { 595 "Name": "main", 596 "Sharded": true 597 }, 598 "FieldQuery": "select s_nationkey, count(*), weight_string(s_nationkey) from supplier where 1 != 1 group by s_nationkey, weight_string(s_nationkey)", 599 "Query": "select s_nationkey, count(*), weight_string(s_nationkey) from supplier where s_suppkey = :l_suppkey group by s_nationkey, weight_string(s_nationkey)", 600 "Table": "supplier", 601 "Values": [ 602 ":l_suppkey" 603 ], 604 "Vindex": "hash" 605 }, 606 { 607 "OperatorType": "Route", 608 "Variant": "EqualUnique", 609 "Keyspace": { 610 "Name": "main", 611 "Sharded": true 612 }, 613 "FieldQuery": "select n1.n_name, n1.n_name as supp_nation, count(*), weight_string(n1.n_name), weight_string(n1.n_name), weight_string(n1.n_name) from nation as n1 where 1 != 1 group by n1.n_name, weight_string(n1.n_name), supp_nation, weight_string(supp_nation)", 614 "Query": "select n1.n_name, n1.n_name as supp_nation, count(*), weight_string(n1.n_name), weight_string(n1.n_name), weight_string(n1.n_name) from nation as n1 where n1.n_nationkey = :s_nationkey group by n1.n_name, weight_string(n1.n_name), supp_nation, weight_string(supp_nation)", 615 "Table": "nation", 616 "Values": [ 617 ":s_nationkey" 618 ], 619 "Vindex": "hash" 620 } 621 ] 622 } 623 ] 624 }, 625 { 626 "OperatorType": "Join", 627 "Variant": "Join", 628 "JoinColumnIndexes": "R:0,R:0,R:2,L:1,R:1,R:3", 629 "JoinVars": { 630 "c_nationkey": 0 631 }, 632 "TableName": "customer_nation", 633 "Inputs": [ 634 { 635 "OperatorType": "Route", 636 "Variant": "EqualUnique", 637 "Keyspace": { 638 "Name": "main", 639 "Sharded": true 640 }, 641 "FieldQuery": "select c_nationkey, count(*), weight_string(c_nationkey) from customer where 1 != 1 group by c_nationkey, weight_string(c_nationkey)", 642 "Query": "select c_nationkey, count(*), weight_string(c_nationkey) from customer where c_custkey = :o_custkey group by c_nationkey, weight_string(c_nationkey)", 643 "Table": "customer", 644 "Values": [ 645 ":o_custkey" 646 ], 647 "Vindex": "hash" 648 }, 649 { 650 "OperatorType": "Route", 651 "Variant": "EqualUnique", 652 "Keyspace": { 653 "Name": "main", 654 "Sharded": true 655 }, 656 "FieldQuery": "select n2.n_name as cust_nation, count(*), weight_string(n2.n_name), weight_string(n2.n_name) from nation as n2 where 1 != 1 group by cust_nation, weight_string(cust_nation)", 657 "Query": "select n2.n_name as cust_nation, count(*), weight_string(n2.n_name), weight_string(n2.n_name) from nation as n2 where n2.n_nationkey = :c_nationkey and (:n1_n_name = 'FRANCE' and n2.n_name = 'GERMANY' or :n1_n_name = 'GERMANY' and n2.n_name = 'FRANCE') group by cust_nation, weight_string(cust_nation)", 658 "Table": "nation", 659 "Values": [ 660 ":c_nationkey" 661 ], 662 "Vindex": "hash" 663 } 664 ] 665 } 666 ] 667 } 668 ] 669 } 670 ] 671 } 672 ] 673 }, 674 "TablesUsed": [ 675 "main.customer", 676 "main.lineitem", 677 "main.nation", 678 "main.orders", 679 "main.supplier" 680 ] 681 } 682 }, 683 { 684 "comment": "TPC-H query 8", 685 "query": "select o_year, sum(case when nation = 'BRAZIL' then volume else 0 end) / sum(volume) as mkt_share from ( select extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) as volume, n2.n_name as nation from part, supplier, lineitem, orders, customer, nation n1, nation n2, region where p_partkey = l_partkey and s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name = 'AMERICA' and s_nationkey = n2.n_nationkey and o_orderdate between date '1995-01-01' and date('1996-12-31') and p_type = 'ECONOMY ANODIZED STEEL' ) as all_nations group by o_year order by o_year", 686 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 687 "gen4-plan": "VT12001: unsupported: in scatter query: complex aggregate expression" 688 }, 689 { 690 "comment": "TPC-H query 9", 691 "query": "select nation, o_year, sum(amount) as sum_profit from ( select n_name as nation, extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) - ps_supplycost * l_quantity as amount from part, supplier, lineitem, partsupp, orders, nation where s_suppkey = l_suppkey and ps_suppkey = l_suppkey and ps_partkey = l_partkey and p_partkey = l_partkey and o_orderkey = l_orderkey and s_nationkey = n_nationkey and p_name like '%green%' ) as profit group by nation, o_year order by nation, o_year desc", 692 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 693 "gen4-plan": "VT12001: unsupported: aggregation on columns from different sources" 694 }, 695 { 696 "comment": "TPC-H query 10", 697 "query": "select c_custkey, c_name, sum(l_extendedprice * (1 - l_discount)) as revenue, c_acctbal, n_name, c_address, c_phone, c_comment from customer, orders, lineitem, nation where c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate >= date('1993-10-01') and o_orderdate < date('1993-10-01') + interval '3' month and l_returnflag = 'R' and c_nationkey = n_nationkey group by c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment order by revenue desc limit 20", 698 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 699 "gen4-plan": { 700 "QueryType": "SELECT", 701 "Original": "select c_custkey, c_name, sum(l_extendedprice * (1 - l_discount)) as revenue, c_acctbal, n_name, c_address, c_phone, c_comment from customer, orders, lineitem, nation where c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate >= date('1993-10-01') and o_orderdate < date('1993-10-01') + interval '3' month and l_returnflag = 'R' and c_nationkey = n_nationkey group by c_custkey, c_name, c_acctbal, c_phone, n_name, c_address, c_comment order by revenue desc limit 20", 702 "Instructions": { 703 "OperatorType": "Limit", 704 "Count": "INT64(20)", 705 "Inputs": [ 706 { 707 "OperatorType": "Sort", 708 "Variant": "Memory", 709 "OrderBy": "2 DESC", 710 "ResultColumns": 8, 711 "Inputs": [ 712 { 713 "OperatorType": "Aggregate", 714 "Variant": "Ordered", 715 "Aggregates": "sum(2) AS revenue", 716 "GroupBy": "(0|14), (1|13), (3|12), (6|11), (4|10), (5|9), (7|8)", 717 "Inputs": [ 718 { 719 "OperatorType": "Projection", 720 "Expressions": [ 721 "[COLUMN 0] as c_custkey", 722 "[COLUMN 1] as c_name", 723 "(([COLUMN 14] * COALESCE([COLUMN 15], INT64(1))) * COALESCE([COLUMN 16], INT64(1))) * COALESCE([COLUMN 17], INT64(1)) as revenue", 724 "[COLUMN 2] as c_acctbal", 725 "[COLUMN 4] as n_name", 726 "[COLUMN 5] as c_address", 727 "[COLUMN 3] as c_phone", 728 "[COLUMN 6] as c_comment", 729 "[COLUMN 13]", 730 "[COLUMN 12]", 731 "[COLUMN 11]", 732 "[COLUMN 10]", 733 "[COLUMN 9]", 734 "[COLUMN 8]", 735 "[COLUMN 7]" 736 ], 737 "Inputs": [ 738 { 739 "OperatorType": "Sort", 740 "Variant": "Memory", 741 "OrderBy": "(0|7) ASC, (1|8) ASC, (2|9) ASC, (3|10) ASC, (4|11) ASC, (5|12) ASC, (6|13) ASC", 742 "Inputs": [ 743 { 744 "OperatorType": "Join", 745 "Variant": "Join", 746 "JoinColumnIndexes": "R:0,R:1,R:2,R:3,R:4,R:5,R:6,R:7,R:8,R:9,R:10,R:11,R:12,R:13,L:3,L:4,R:14,R:15", 747 "JoinVars": { 748 "o_custkey": 0 749 }, 750 "TableName": "orders_lineitem_customer_nation", 751 "Inputs": [ 752 { 753 "OperatorType": "Join", 754 "Variant": "Join", 755 "JoinColumnIndexes": "L:1,L:1,L:4,L:2,R:1", 756 "JoinVars": { 757 "o_orderkey": 0 758 }, 759 "TableName": "orders_lineitem", 760 "Inputs": [ 761 { 762 "OperatorType": "Route", 763 "Variant": "Scatter", 764 "Keyspace": { 765 "Name": "main", 766 "Sharded": true 767 }, 768 "FieldQuery": "select o_orderkey, o_custkey, count(*), weight_string(o_orderkey), weight_string(o_custkey) from orders where 1 != 1 group by o_orderkey, weight_string(o_orderkey), o_custkey, weight_string(o_custkey)", 769 "Query": "select o_orderkey, o_custkey, count(*), weight_string(o_orderkey), weight_string(o_custkey) from orders where o_orderdate >= date('1993-10-01') and o_orderdate < date('1993-10-01') + interval '3' month group by o_orderkey, weight_string(o_orderkey), o_custkey, weight_string(o_custkey)", 770 "Table": "orders" 771 }, 772 { 773 "OperatorType": "VindexLookup", 774 "Variant": "EqualUnique", 775 "Keyspace": { 776 "Name": "main", 777 "Sharded": true 778 }, 779 "Values": [ 780 ":o_orderkey" 781 ], 782 "Vindex": "lineitem_map", 783 "Inputs": [ 784 { 785 "OperatorType": "Route", 786 "Variant": "IN", 787 "Keyspace": { 788 "Name": "main", 789 "Sharded": true 790 }, 791 "FieldQuery": "select l_orderkey, l_linenumber from lineitem_map where 1 != 1", 792 "Query": "select l_orderkey, l_linenumber from lineitem_map where l_orderkey in ::__vals", 793 "Table": "lineitem_map", 794 "Values": [ 795 ":l_orderkey" 796 ], 797 "Vindex": "md5" 798 }, 799 { 800 "OperatorType": "Route", 801 "Variant": "ByDestination", 802 "Keyspace": { 803 "Name": "main", 804 "Sharded": true 805 }, 806 "FieldQuery": "select 1, sum(l_extendedprice * (1 - l_discount)) as revenue from lineitem where 1 != 1 group by 1", 807 "Query": "select 1, sum(l_extendedprice * (1 - l_discount)) as revenue from lineitem where l_returnflag = 'R' and l_orderkey = :o_orderkey group by 1", 808 "Table": "lineitem" 809 } 810 ] 811 } 812 ] 813 }, 814 { 815 "OperatorType": "Join", 816 "Variant": "Join", 817 "JoinColumnIndexes": "L:3,L:5,L:7,L:9,R:1,L:11,L:13,L:4,L:6,L:8,L:10,R:2,L:12,L:14,L:1,R:0", 818 "JoinVars": { 819 "c_nationkey": 0 820 }, 821 "TableName": "customer_nation", 822 "Inputs": [ 823 { 824 "OperatorType": "Route", 825 "Variant": "EqualUnique", 826 "Keyspace": { 827 "Name": "main", 828 "Sharded": true 829 }, 830 "FieldQuery": "select c_nationkey, count(*), weight_string(c_nationkey), c_custkey, weight_string(c_custkey), c_name, weight_string(c_name), c_acctbal, weight_string(c_acctbal), c_phone, weight_string(c_phone), c_address, weight_string(c_address), c_comment, weight_string(c_comment) from customer where 1 != 1 group by c_nationkey, weight_string(c_nationkey), c_custkey, weight_string(c_custkey), c_name, weight_string(c_name), c_acctbal, weight_string(c_acctbal), c_phone, weight_string(c_phone), c_address, weight_string(c_address), c_comment, weight_string(c_comment)", 831 "Query": "select c_nationkey, count(*), weight_string(c_nationkey), c_custkey, weight_string(c_custkey), c_name, weight_string(c_name), c_acctbal, weight_string(c_acctbal), c_phone, weight_string(c_phone), c_address, weight_string(c_address), c_comment, weight_string(c_comment) from customer where c_custkey = :o_custkey group by c_nationkey, weight_string(c_nationkey), c_custkey, weight_string(c_custkey), c_name, weight_string(c_name), c_acctbal, weight_string(c_acctbal), c_phone, weight_string(c_phone), c_address, weight_string(c_address), c_comment, weight_string(c_comment)", 832 "Table": "customer", 833 "Values": [ 834 ":o_custkey" 835 ], 836 "Vindex": "hash" 837 }, 838 { 839 "OperatorType": "Route", 840 "Variant": "EqualUnique", 841 "Keyspace": { 842 "Name": "main", 843 "Sharded": true 844 }, 845 "FieldQuery": "select count(*), n_name, weight_string(n_name) from nation where 1 != 1 group by n_name, weight_string(n_name)", 846 "Query": "select count(*), n_name, weight_string(n_name) from nation where n_nationkey = :c_nationkey group by n_name, weight_string(n_name)", 847 "Table": "nation", 848 "Values": [ 849 ":c_nationkey" 850 ], 851 "Vindex": "hash" 852 } 853 ] 854 } 855 ] 856 } 857 ] 858 } 859 ] 860 } 861 ] 862 } 863 ] 864 } 865 ] 866 }, 867 "TablesUsed": [ 868 "main.customer", 869 "main.lineitem", 870 "main.nation", 871 "main.orders" 872 ] 873 } 874 }, 875 { 876 "comment": "TPC-H query 11", 877 "query": "select ps_partkey, sum(ps_supplycost * ps_availqty) as value from partsupp, supplier, nation where ps_suppkey = s_suppkey and s_nationkey = n_nationkey and n_name = 'GERMANY' group by ps_partkey having sum(ps_supplycost * ps_availqty) > ( select sum(ps_supplycost * ps_availqty) * 0.00001000000 from partsupp, supplier, nation where ps_suppkey = s_suppkey and s_nationkey = n_nationkey and n_name = 'GERMANY' ) order by value desc", 878 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 879 "gen4-plan": "VT12001: unsupported: in scatter query: complex aggregate expression" 880 }, 881 { 882 "comment": "TPC-H query 12", 883 "query": "select l_shipmode, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' and o_orderpriority <> '2-HIGH' then 1 else 0 end) as low_line_count from orders, lineitem where o_orderkey = l_orderkey and l_shipmode in ('MAIL', 'SHIP') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date('1994-01-01') and l_receiptdate < date('1994-01-01') + interval '1' year group by l_shipmode order by l_shipmode", 884 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 885 "gen4-plan": { 886 "QueryType": "SELECT", 887 "Original": "select l_shipmode, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority <> '1-URGENT' and o_orderpriority <> '2-HIGH' then 1 else 0 end) as low_line_count from orders, lineitem where o_orderkey = l_orderkey and l_shipmode in ('MAIL', 'SHIP') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date('1994-01-01') and l_receiptdate < date('1994-01-01') + interval '1' year group by l_shipmode order by l_shipmode", 888 "Instructions": { 889 "OperatorType": "Aggregate", 890 "Variant": "Ordered", 891 "Aggregates": "sum(1) AS high_line_count, sum(2) AS low_line_count", 892 "GroupBy": "(0|3)", 893 "ResultColumns": 3, 894 "Inputs": [ 895 { 896 "OperatorType": "Projection", 897 "Expressions": [ 898 "[COLUMN 0] as l_shipmode", 899 "[COLUMN 2] * COALESCE([COLUMN 3], INT64(1)) as high_line_count", 900 "[COLUMN 4] * COALESCE([COLUMN 5], INT64(1)) as low_line_count", 901 "[COLUMN 1]" 902 ], 903 "Inputs": [ 904 { 905 "OperatorType": "Sort", 906 "Variant": "Memory", 907 "OrderBy": "(0|1) ASC", 908 "Inputs": [ 909 { 910 "OperatorType": "Join", 911 "Variant": "Join", 912 "JoinColumnIndexes": "R:1,R:2,L:1,R:0,L:2,R:0", 913 "JoinVars": { 914 "o_orderkey": 0 915 }, 916 "TableName": "orders_lineitem", 917 "Inputs": [ 918 { 919 "OperatorType": "Route", 920 "Variant": "Scatter", 921 "Keyspace": { 922 "Name": "main", 923 "Sharded": true 924 }, 925 "FieldQuery": "select o_orderkey, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority != '1-URGENT' and o_orderpriority != '2-HIGH' then 1 else 0 end) as low_line_count, weight_string(o_orderkey) from orders where 1 != 1 group by o_orderkey, weight_string(o_orderkey)", 926 "Query": "select o_orderkey, sum(case when o_orderpriority = '1-URGENT' or o_orderpriority = '2-HIGH' then 1 else 0 end) as high_line_count, sum(case when o_orderpriority != '1-URGENT' and o_orderpriority != '2-HIGH' then 1 else 0 end) as low_line_count, weight_string(o_orderkey) from orders group by o_orderkey, weight_string(o_orderkey)", 927 "Table": "orders" 928 }, 929 { 930 "OperatorType": "VindexLookup", 931 "Variant": "EqualUnique", 932 "Keyspace": { 933 "Name": "main", 934 "Sharded": true 935 }, 936 "Values": [ 937 ":o_orderkey" 938 ], 939 "Vindex": "lineitem_map", 940 "Inputs": [ 941 { 942 "OperatorType": "Route", 943 "Variant": "IN", 944 "Keyspace": { 945 "Name": "main", 946 "Sharded": true 947 }, 948 "FieldQuery": "select l_orderkey, l_linenumber from lineitem_map where 1 != 1", 949 "Query": "select l_orderkey, l_linenumber from lineitem_map where l_orderkey in ::__vals", 950 "Table": "lineitem_map", 951 "Values": [ 952 ":l_orderkey" 953 ], 954 "Vindex": "md5" 955 }, 956 { 957 "OperatorType": "Route", 958 "Variant": "ByDestination", 959 "Keyspace": { 960 "Name": "main", 961 "Sharded": true 962 }, 963 "FieldQuery": "select count(*), l_shipmode, weight_string(l_shipmode) from lineitem where 1 != 1 group by l_shipmode, weight_string(l_shipmode)", 964 "Query": "select count(*), l_shipmode, weight_string(l_shipmode) from lineitem where l_shipmode in ('MAIL', 'SHIP') and l_commitdate < l_receiptdate and l_shipdate < l_commitdate and l_receiptdate >= date('1994-01-01') and l_receiptdate < date('1994-01-01') + interval '1' year and l_orderkey = :o_orderkey group by l_shipmode, weight_string(l_shipmode)", 965 "Table": "lineitem" 966 } 967 ] 968 } 969 ] 970 } 971 ] 972 } 973 ] 974 } 975 ] 976 }, 977 "TablesUsed": [ 978 "main.lineitem", 979 "main.orders" 980 ] 981 } 982 }, 983 { 984 "comment": "TPC-H query 13", 985 "query": "select c_count, count(*) as custdist from ( select c_custkey, count(o_orderkey) from customer left outer join orders on c_custkey = o_custkey and o_comment not like '%special%requests%' group by c_custkey ) as c_orders(c_custkey, c_count) group by c_count order by custdist desc, c_count desc", 986 "plan": "VT12001: unsupported: using aggregation on top of a *planbuilder.orderedAggregate plan" 987 }, 988 { 989 "comment": "TPC-H query 14", 990 "query": "select 100.00 * sum(case when p_type like 'PROMO%' then l_extendedprice * (1 - l_discount) else 0 end) / sum(l_extendedprice * (1 - l_discount)) as promo_revenue from lineitem, part where l_partkey = p_partkey and l_shipdate >= date('1995-09-01') and l_shipdate < date('1995-09-01') + interval '1' month", 991 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 992 "gen4-plan": "VT12001: unsupported: in scatter query: complex aggregate expression" 993 }, 994 { 995 "comment": "TPC-H query 15 view\n#\"with revenue0(supplier_no, total_revenue) as (select l_suppkey, sum(l_extendedprice * (1 - l_discount)) from lineitem where l_shipdate >= date('1996-01-01') and l_shipdate < date('1996-01-01') + interval '3' month group by l_suppkey )\"\n#\"syntax error at position 236\"\n#Gen4 plan same as above\n# TPC-H query 15", 996 "query": "select s_suppkey, s_name, s_address, s_phone, total_revenue from supplier, revenue0 where s_suppkey = supplier_no and total_revenue = ( select max(total_revenue) from revenue0 ) order by s_suppkey", 997 "v3-plan": { 998 "QueryType": "SELECT", 999 "Original": "select s_suppkey, s_name, s_address, s_phone, total_revenue from supplier, revenue0 where s_suppkey = supplier_no and total_revenue = ( select max(total_revenue) from revenue0 ) order by s_suppkey", 1000 "Instructions": { 1001 "OperatorType": "Subquery", 1002 "Variant": "PulloutValue", 1003 "PulloutVars": [ 1004 "__sq_has_values1", 1005 "__sq1" 1006 ], 1007 "Inputs": [ 1008 { 1009 "OperatorType": "Aggregate", 1010 "Variant": "Scalar", 1011 "Aggregates": "max(0)", 1012 "Inputs": [ 1013 { 1014 "OperatorType": "Route", 1015 "Variant": "Scatter", 1016 "Keyspace": { 1017 "Name": "main", 1018 "Sharded": true 1019 }, 1020 "FieldQuery": "select max(total_revenue) from revenue0 where 1 != 1", 1021 "Query": "select max(total_revenue) from revenue0", 1022 "Table": "revenue0" 1023 } 1024 ] 1025 }, 1026 { 1027 "OperatorType": "Join", 1028 "Variant": "Join", 1029 "JoinColumnIndexes": "L:0,L:1,L:2,L:3,R:0", 1030 "JoinVars": { 1031 "s_suppkey": 0 1032 }, 1033 "TableName": "supplier_revenue0", 1034 "Inputs": [ 1035 { 1036 "OperatorType": "Route", 1037 "Variant": "Scatter", 1038 "Keyspace": { 1039 "Name": "main", 1040 "Sharded": true 1041 }, 1042 "FieldQuery": "select s_suppkey, s_name, s_address, s_phone, weight_string(s_suppkey) from supplier where 1 != 1", 1043 "OrderBy": "(0|4) ASC", 1044 "Query": "select s_suppkey, s_name, s_address, s_phone, weight_string(s_suppkey) from supplier order by s_suppkey asc", 1045 "ResultColumns": 4, 1046 "Table": "supplier" 1047 }, 1048 { 1049 "OperatorType": "Route", 1050 "Variant": "EqualUnique", 1051 "Keyspace": { 1052 "Name": "main", 1053 "Sharded": true 1054 }, 1055 "FieldQuery": "select total_revenue from revenue0 where 1 != 1", 1056 "Query": "select total_revenue from revenue0 where supplier_no = :s_suppkey and total_revenue = :__sq1", 1057 "Table": "revenue0", 1058 "Values": [ 1059 ":s_suppkey" 1060 ], 1061 "Vindex": "hash" 1062 } 1063 ] 1064 } 1065 ] 1066 } 1067 }, 1068 "gen4-plan": { 1069 "QueryType": "SELECT", 1070 "Original": "select s_suppkey, s_name, s_address, s_phone, total_revenue from supplier, revenue0 where s_suppkey = supplier_no and total_revenue = ( select max(total_revenue) from revenue0 ) order by s_suppkey", 1071 "Instructions": { 1072 "OperatorType": "Subquery", 1073 "Variant": "PulloutValue", 1074 "PulloutVars": [ 1075 "__sq_has_values1", 1076 "__sq1" 1077 ], 1078 "Inputs": [ 1079 { 1080 "OperatorType": "Aggregate", 1081 "Variant": "Scalar", 1082 "Aggregates": "max(0) AS max(total_revenue)", 1083 "Inputs": [ 1084 { 1085 "OperatorType": "Route", 1086 "Variant": "Scatter", 1087 "Keyspace": { 1088 "Name": "main", 1089 "Sharded": true 1090 }, 1091 "FieldQuery": "select max(total_revenue) from revenue0 where 1 != 1", 1092 "Query": "select max(total_revenue) from revenue0", 1093 "Table": "revenue0" 1094 } 1095 ] 1096 }, 1097 { 1098 "OperatorType": "Route", 1099 "Variant": "Scatter", 1100 "Keyspace": { 1101 "Name": "main", 1102 "Sharded": true 1103 }, 1104 "FieldQuery": "select s_suppkey, s_name, s_address, s_phone, total_revenue, weight_string(s_suppkey) from supplier, revenue0 where 1 != 1", 1105 "OrderBy": "(0|5) ASC", 1106 "Query": "select s_suppkey, s_name, s_address, s_phone, total_revenue, weight_string(s_suppkey) from supplier, revenue0 where total_revenue = :__sq1 and s_suppkey = supplier_no order by s_suppkey asc", 1107 "ResultColumns": 5, 1108 "Table": "revenue0, supplier" 1109 } 1110 ] 1111 }, 1112 "TablesUsed": [ 1113 "main.revenue0", 1114 "main.supplier" 1115 ] 1116 } 1117 }, 1118 { 1119 "comment": "TPC-H query 16", 1120 "query": "select p_brand, p_type, p_size, count(distinct ps_suppkey) as supplier_cnt from partsupp, part where p_partkey = ps_partkey and p_brand <> 'Brand#45' and p_type not like 'MEDIUM POLISHED%' and p_size in (49, 14, 23, 45, 19, 3, 36, 9) and ps_suppkey not in ( select s_suppkey from supplier where s_comment like '%Customer%Complaints%' ) group by p_brand, p_type, p_size order by supplier_cnt desc, p_brand, p_type, p_size", 1121 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 1122 "gen4-plan": "VT12001: unsupported: using aggregation on top of a *planbuilder.pulloutSubquery plan" 1123 }, 1124 { 1125 "comment": "TPC-H query 17", 1126 "query": "select sum(l_extendedprice) / 7.0 as avg_yearly from lineitem, part where p_partkey = l_partkey and p_brand = 'Brand#23' and p_container = 'MED BOX' and l_quantity < ( select 0.2 * avg(l_quantity) from lineitem where l_partkey = p_partkey )", 1127 "v3-plan": "VT03019: symbol p_partkey not found", 1128 "gen4-plan": "VT12001: unsupported: cross-shard correlated subquery" 1129 }, 1130 { 1131 "comment": "TPC-H query 18", 1132 "query": "select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, lineitem where o_orderkey in ( select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > 300 ) and c_custkey = o_custkey and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate limit 100", 1133 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 1134 "gen4-plan": { 1135 "QueryType": "SELECT", 1136 "Original": "select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, lineitem where o_orderkey in ( select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > 300 ) and c_custkey = o_custkey and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate limit 100", 1137 "Instructions": { 1138 "OperatorType": "Limit", 1139 "Count": "INT64(100)", 1140 "Inputs": [ 1141 { 1142 "OperatorType": "Aggregate", 1143 "Variant": "Ordered", 1144 "Aggregates": "sum(5) AS sum(l_quantity)", 1145 "GroupBy": "(4|10), (3|9), (0|8), (1|7), (2|6)", 1146 "ResultColumns": 6, 1147 "Inputs": [ 1148 { 1149 "OperatorType": "Projection", 1150 "Expressions": [ 1151 "[COLUMN 2] as c_name", 1152 "[COLUMN 3] as c_custkey", 1153 "[COLUMN 4] as o_orderkey", 1154 "[COLUMN 1] as o_orderdate", 1155 "[COLUMN 0] as o_totalprice", 1156 "([COLUMN 10] * COALESCE([COLUMN 11], INT64(1))) * COALESCE([COLUMN 12], INT64(1)) as sum(l_quantity)", 1157 "[COLUMN 9]", 1158 "[COLUMN 8]", 1159 "[COLUMN 7]", 1160 "[COLUMN 6]", 1161 "[COLUMN 5]" 1162 ], 1163 "Inputs": [ 1164 { 1165 "OperatorType": "Join", 1166 "Variant": "Join", 1167 "JoinColumnIndexes": "L:2,L:3,L:4,L:5,L:6,L:8,L:9,L:10,L:11,L:12,L:13,L:14,R:1", 1168 "JoinVars": { 1169 "o_orderkey": 0 1170 }, 1171 "TableName": "orders_customer_lineitem", 1172 "Inputs": [ 1173 { 1174 "OperatorType": "Sort", 1175 "Variant": "Memory", 1176 "OrderBy": "(2|8) DESC, (3|9) ASC, (4|10) ASC, (5|11) ASC, (0|7) ASC", 1177 "Inputs": [ 1178 { 1179 "OperatorType": "Join", 1180 "Variant": "Join", 1181 "JoinColumnIndexes": "L:1,L:1,L:5,L:7,R:1,R:3,L:1,L:4,L:6,L:8,R:2,R:4,L:4,L:2,R:0", 1182 "JoinVars": { 1183 "o_custkey": 0 1184 }, 1185 "TableName": "orders_customer", 1186 "Inputs": [ 1187 { 1188 "OperatorType": "Route", 1189 "Variant": "IN", 1190 "Keyspace": { 1191 "Name": "main", 1192 "Sharded": true 1193 }, 1194 "FieldQuery": "select o_custkey, o_orderkey, count(*), weight_string(o_custkey), weight_string(o_orderkey), o_totalprice, weight_string(o_totalprice), o_orderdate, weight_string(o_orderdate) from orders where 1 != 1 group by o_custkey, weight_string(o_custkey), o_orderkey, weight_string(o_orderkey), o_totalprice, weight_string(o_totalprice), o_orderdate, weight_string(o_orderdate)", 1195 "Query": "select o_custkey, o_orderkey, count(*), weight_string(o_custkey), weight_string(o_orderkey), o_totalprice, weight_string(o_totalprice), o_orderdate, weight_string(o_orderdate) from orders where :o_orderkey in (select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > 300) group by o_custkey, weight_string(o_custkey), o_orderkey, weight_string(o_orderkey), o_totalprice, weight_string(o_totalprice), o_orderdate, weight_string(o_orderdate)", 1196 "Table": "orders", 1197 "Values": [ 1198 ":__sq1" 1199 ], 1200 "Vindex": "hash" 1201 }, 1202 { 1203 "OperatorType": "Route", 1204 "Variant": "EqualUnique", 1205 "Keyspace": { 1206 "Name": "main", 1207 "Sharded": true 1208 }, 1209 "FieldQuery": "select count(*), c_name, weight_string(c_name), c_custkey, weight_string(c_custkey) from customer where 1 != 1 group by c_name, weight_string(c_name), c_custkey, weight_string(c_custkey)", 1210 "Query": "select count(*), c_name, weight_string(c_name), c_custkey, weight_string(c_custkey) from customer where c_custkey = :o_custkey group by c_name, weight_string(c_name), c_custkey, weight_string(c_custkey)", 1211 "Table": "customer", 1212 "Values": [ 1213 ":o_custkey" 1214 ], 1215 "Vindex": "hash" 1216 } 1217 ] 1218 } 1219 ] 1220 }, 1221 { 1222 "OperatorType": "VindexLookup", 1223 "Variant": "EqualUnique", 1224 "Keyspace": { 1225 "Name": "main", 1226 "Sharded": true 1227 }, 1228 "Values": [ 1229 ":o_orderkey" 1230 ], 1231 "Vindex": "lineitem_map", 1232 "Inputs": [ 1233 { 1234 "OperatorType": "Route", 1235 "Variant": "IN", 1236 "Keyspace": { 1237 "Name": "main", 1238 "Sharded": true 1239 }, 1240 "FieldQuery": "select l_orderkey, l_linenumber from lineitem_map where 1 != 1", 1241 "Query": "select l_orderkey, l_linenumber from lineitem_map where l_orderkey in ::__vals", 1242 "Table": "lineitem_map", 1243 "Values": [ 1244 ":l_orderkey" 1245 ], 1246 "Vindex": "md5" 1247 }, 1248 { 1249 "OperatorType": "Route", 1250 "Variant": "ByDestination", 1251 "Keyspace": { 1252 "Name": "main", 1253 "Sharded": true 1254 }, 1255 "FieldQuery": "select 1, sum(l_quantity) from lineitem where 1 != 1 group by 1", 1256 "Query": "select 1, sum(l_quantity) from lineitem where l_orderkey = :o_orderkey group by 1", 1257 "Table": "lineitem" 1258 } 1259 ] 1260 } 1261 ] 1262 } 1263 ] 1264 } 1265 ] 1266 } 1267 ] 1268 }, 1269 "TablesUsed": [ 1270 "main.customer", 1271 "main.lineitem", 1272 "main.orders" 1273 ] 1274 } 1275 }, 1276 { 1277 "comment": "TPC-H query 19", 1278 "query": "select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey = l_partkey and p_brand = 'Brand#12' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 1 and l_quantity <= 1 + 10 and p_size between 1 and 5 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#23' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 10 and l_quantity <= 10 + 10 and p_size between 1 and 10 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#34' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 20 and l_quantity <= 20 + 10 and p_size between 1 and 15 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' )", 1279 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 1280 "gen4-plan": { 1281 "QueryType": "SELECT", 1282 "Original": "select sum(l_extendedprice* (1 - l_discount)) as revenue from lineitem, part where ( p_partkey = l_partkey and p_brand = 'Brand#12' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and l_quantity >= 1 and l_quantity <= 1 + 10 and p_size between 1 and 5 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#23' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and l_quantity >= 10 and l_quantity <= 10 + 10 and p_size between 1 and 10 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' ) or ( p_partkey = l_partkey and p_brand = 'Brand#34' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and l_quantity >= 20 and l_quantity <= 20 + 10 and p_size between 1 and 15 and l_shipmode in ('AIR', 'AIR REG') and l_shipinstruct = 'DELIVER IN PERSON' )", 1283 "Instructions": { 1284 "OperatorType": "Aggregate", 1285 "Variant": "Scalar", 1286 "Aggregates": "sum(0) AS revenue", 1287 "Inputs": [ 1288 { 1289 "OperatorType": "Projection", 1290 "Expressions": [ 1291 "[COLUMN 0] * COALESCE([COLUMN 1], INT64(1)) as revenue" 1292 ], 1293 "Inputs": [ 1294 { 1295 "OperatorType": "Join", 1296 "Variant": "Join", 1297 "JoinColumnIndexes": "L:4,R:1", 1298 "JoinVars": { 1299 "l_partkey": 0, 1300 "l_quantity": 1, 1301 "l_shipinstruct": 3, 1302 "l_shipmode": 2 1303 }, 1304 "TableName": "lineitem_part", 1305 "Inputs": [ 1306 { 1307 "OperatorType": "Route", 1308 "Variant": "Scatter", 1309 "Keyspace": { 1310 "Name": "main", 1311 "Sharded": true 1312 }, 1313 "FieldQuery": "select l_partkey, l_quantity, l_shipmode, l_shipinstruct, sum(l_extendedprice * (1 - l_discount)) as revenue, weight_string(l_partkey), weight_string(l_quantity), weight_string(l_shipmode), weight_string(l_shipinstruct) from lineitem where 1 != 1 group by l_partkey, weight_string(l_partkey), l_quantity, weight_string(l_quantity), l_shipmode, weight_string(l_shipmode), l_shipinstruct, weight_string(l_shipinstruct)", 1314 "Query": "select l_partkey, l_quantity, l_shipmode, l_shipinstruct, sum(l_extendedprice * (1 - l_discount)) as revenue, weight_string(l_partkey), weight_string(l_quantity), weight_string(l_shipmode), weight_string(l_shipinstruct) from lineitem group by l_partkey, weight_string(l_partkey), l_quantity, weight_string(l_quantity), l_shipmode, weight_string(l_shipmode), l_shipinstruct, weight_string(l_shipinstruct)", 1315 "Table": "lineitem" 1316 }, 1317 { 1318 "OperatorType": "Route", 1319 "Variant": "Scatter", 1320 "Keyspace": { 1321 "Name": "main", 1322 "Sharded": true 1323 }, 1324 "FieldQuery": "select 1, count(*) from part where 1 != 1 group by 1", 1325 "Query": "select 1, count(*) from part where p_partkey = :l_partkey and p_brand = 'Brand#12' and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') and :l_quantity >= 1 and :l_quantity <= 1 + 10 and p_size between 1 and 5 and :l_shipmode in ('AIR', 'AIR REG') and :l_shipinstruct = 'DELIVER IN PERSON' or p_partkey = :l_partkey and p_brand = 'Brand#23' and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') and :l_quantity >= 10 and :l_quantity <= 10 + 10 and p_size between 1 and 10 and :l_shipmode in ('AIR', 'AIR REG') and :l_shipinstruct = 'DELIVER IN PERSON' or p_partkey = :l_partkey and p_brand = 'Brand#34' and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') and :l_quantity >= 20 and :l_quantity <= 20 + 10 and p_size between 1 and 15 and :l_shipmode in ('AIR', 'AIR REG') and :l_shipinstruct = 'DELIVER IN PERSON' group by 1", 1326 "Table": "part" 1327 } 1328 ] 1329 } 1330 ] 1331 } 1332 ] 1333 }, 1334 "TablesUsed": [ 1335 "main.lineitem", 1336 "main.part" 1337 ] 1338 } 1339 }, 1340 { 1341 "comment": "TPC-H query 20", 1342 "query": "select s_name, s_address from supplier, nation where s_suppkey in ( select ps_suppkey from partsupp where ps_partkey in ( select p_partkey from part where p_name like 'forest%' ) and ps_availqty > ( select 0.5 * sum(l_quantity) from lineitem where l_partkey = ps_partkey and l_suppkey = ps_suppkey and l_shipdate >= date('1994-01-01') and l_shipdate < date('1994-01-01') + interval '1' year ) ) and s_nationkey = n_nationkey and n_name = 'CANADA' order by s_name", 1343 "v3-plan": "VT03019: symbol ps_partkey not found", 1344 "gen4-plan": "VT12001: unsupported: cross-shard correlated subquery" 1345 }, 1346 { 1347 "comment": "TPC-H query 21", 1348 "query": "select s_name, count(*) as numwait from supplier, lineitem l1, orders, nation where s_suppkey = l1.l_suppkey and o_orderkey = l1.l_orderkey and o_orderstatus = 'F' and l1.l_receiptdate > l1.l_commitdate and exists ( select * from lineitem l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey <> l1.l_suppkey ) and not exists ( select * from lineitem l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey <> l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate ) and s_nationkey = n_nationkey and n_name = 'SAUDI ARABIA' group by s_name order by numwait desc, s_name limit 100", 1349 "v3-plan": "VT12001: unsupported: cross-shard query with aggregates", 1350 "gen4-plan": { 1351 "QueryType": "SELECT", 1352 "Original": "select s_name, count(*) as numwait from supplier, lineitem l1, orders, nation where s_suppkey = l1.l_suppkey and o_orderkey = l1.l_orderkey and o_orderstatus = 'F' and l1.l_receiptdate > l1.l_commitdate and exists ( select * from lineitem l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey <> l1.l_suppkey ) and not exists ( select * from lineitem l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey <> l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate ) and s_nationkey = n_nationkey and n_name = 'SAUDI ARABIA' group by s_name order by numwait desc, s_name limit 100", 1353 "Instructions": { 1354 "OperatorType": "Limit", 1355 "Count": "INT64(100)", 1356 "Inputs": [ 1357 { 1358 "OperatorType": "Sort", 1359 "Variant": "Memory", 1360 "OrderBy": "1 DESC, (0|2) ASC", 1361 "ResultColumns": 2, 1362 "Inputs": [ 1363 { 1364 "OperatorType": "Aggregate", 1365 "Variant": "Ordered", 1366 "Aggregates": "sum_count_star(1) AS numwait", 1367 "GroupBy": "(0|2)", 1368 "Inputs": [ 1369 { 1370 "OperatorType": "Projection", 1371 "Expressions": [ 1372 "[COLUMN 0] as s_name", 1373 "(([COLUMN 2] * COALESCE([COLUMN 3], INT64(1))) * COALESCE([COLUMN 4], INT64(1))) * COALESCE([COLUMN 5], INT64(1)) as numwait", 1374 "[COLUMN 1]" 1375 ], 1376 "Inputs": [ 1377 { 1378 "OperatorType": "Sort", 1379 "Variant": "Memory", 1380 "OrderBy": "(0|1) ASC", 1381 "Inputs": [ 1382 { 1383 "OperatorType": "Join", 1384 "Variant": "Join", 1385 "JoinColumnIndexes": "R:0,R:1,L:3,L:4,R:2,R:3", 1386 "JoinVars": { 1387 "l1_l_suppkey": 0 1388 }, 1389 "TableName": "lineitem_orders_supplier_nation", 1390 "Inputs": [ 1391 { 1392 "OperatorType": "Join", 1393 "Variant": "Join", 1394 "JoinColumnIndexes": "L:1,L:1,L:4,L:2,R:1", 1395 "JoinVars": { 1396 "l1_l_orderkey": 0 1397 }, 1398 "TableName": "lineitem_orders", 1399 "Inputs": [ 1400 { 1401 "OperatorType": "Route", 1402 "Variant": "Scatter", 1403 "Keyspace": { 1404 "Name": "main", 1405 "Sharded": true 1406 }, 1407 "FieldQuery": "select l1.l_orderkey, l1.l_suppkey, count(*) as numwait, weight_string(l1.l_orderkey), weight_string(l1.l_suppkey) from lineitem as l1 where 1 != 1 group by l1.l_orderkey, weight_string(l1.l_orderkey), l1.l_suppkey, weight_string(l1.l_suppkey)", 1408 "Query": "select l1.l_orderkey, l1.l_suppkey, count(*) as numwait, weight_string(l1.l_orderkey), weight_string(l1.l_suppkey) from lineitem as l1 where l1.l_receiptdate > l1.l_commitdate and exists (select 1 from lineitem as l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey != l1.l_suppkey limit 1) and not exists (select 1 from lineitem as l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey != l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate limit 1) group by l1.l_orderkey, weight_string(l1.l_orderkey), l1.l_suppkey, weight_string(l1.l_suppkey)", 1409 "Table": "lineitem" 1410 }, 1411 { 1412 "OperatorType": "Route", 1413 "Variant": "EqualUnique", 1414 "Keyspace": { 1415 "Name": "main", 1416 "Sharded": true 1417 }, 1418 "FieldQuery": "select 1, count(*) as numwait from orders where 1 != 1 group by 1", 1419 "Query": "select 1, count(*) as numwait from orders where o_orderstatus = 'F' and exists (select 1 from lineitem as l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey != l1.l_suppkey limit 1) and not exists (select 1 from lineitem as l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey != l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate limit 1) and o_orderkey = :l1_l_orderkey group by 1", 1420 "Table": "orders", 1421 "Values": [ 1422 ":l1_l_orderkey" 1423 ], 1424 "Vindex": "hash" 1425 } 1426 ] 1427 }, 1428 { 1429 "OperatorType": "Join", 1430 "Variant": "Join", 1431 "JoinColumnIndexes": "L:3,L:4,L:1,R:1", 1432 "JoinVars": { 1433 "s_nationkey": 0 1434 }, 1435 "TableName": "supplier_nation", 1436 "Inputs": [ 1437 { 1438 "OperatorType": "Route", 1439 "Variant": "EqualUnique", 1440 "Keyspace": { 1441 "Name": "main", 1442 "Sharded": true 1443 }, 1444 "FieldQuery": "select s_nationkey, count(*) as numwait, weight_string(s_nationkey), s_name, weight_string(s_name) from supplier where 1 != 1 group by s_nationkey, weight_string(s_nationkey), s_name, weight_string(s_name)", 1445 "Query": "select s_nationkey, count(*) as numwait, weight_string(s_nationkey), s_name, weight_string(s_name) from supplier where exists (select 1 from lineitem as l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey != l1.l_suppkey limit 1) and not exists (select 1 from lineitem as l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey != l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate limit 1) and s_suppkey = :l1_l_suppkey group by s_nationkey, weight_string(s_nationkey), s_name, weight_string(s_name)", 1446 "Table": "supplier", 1447 "Values": [ 1448 ":l1_l_suppkey" 1449 ], 1450 "Vindex": "hash" 1451 }, 1452 { 1453 "OperatorType": "Route", 1454 "Variant": "EqualUnique", 1455 "Keyspace": { 1456 "Name": "main", 1457 "Sharded": true 1458 }, 1459 "FieldQuery": "select 1, count(*) as numwait from nation where 1 != 1 group by 1", 1460 "Query": "select 1, count(*) as numwait from nation where n_name = 'SAUDI ARABIA' and exists (select 1 from lineitem as l2 where l2.l_orderkey = l1.l_orderkey and l2.l_suppkey != l1.l_suppkey limit 1) and not exists (select 1 from lineitem as l3 where l3.l_orderkey = l1.l_orderkey and l3.l_suppkey != l1.l_suppkey and l3.l_receiptdate > l3.l_commitdate limit 1) and n_nationkey = :s_nationkey group by 1", 1461 "Table": "nation", 1462 "Values": [ 1463 ":s_nationkey" 1464 ], 1465 "Vindex": "hash" 1466 } 1467 ] 1468 } 1469 ] 1470 } 1471 ] 1472 } 1473 ] 1474 } 1475 ] 1476 } 1477 ] 1478 } 1479 ] 1480 }, 1481 "TablesUsed": [ 1482 "main.lineitem", 1483 "main.nation", 1484 "main.orders", 1485 "main.supplier" 1486 ] 1487 } 1488 }, 1489 { 1490 "comment": "TPC-H query 22", 1491 "query": "select cntrycode, count(*) as numcust, sum(c_acctbal) as totacctbal from ( select substring(c_phone from 1 for 2) as cntrycode, c_acctbal from customer where substring(c_phone from 1 for 2) in ('13', '31', '23', '29', '30', '18', '17') and c_acctbal > ( select avg(c_acctbal) from customer where c_acctbal > 0.00 and substring(c_phone from 1 for 2) in ('13', '31', '23', '29', '30', '18', '17') ) and not exists ( select * from orders where o_custkey = c_custkey ) ) as custsale group by cntrycode order by cntrycode", 1492 "v3-plan": "VT03019: symbol c_custkey not found", 1493 "gen4-plan": "VT12001: unsupported: EXISTS sub-queries are only supported with AND clause" 1494 } 1495 ]