Skip to content

Commit

Permalink
feat: support TPC-H Q4 for batch (risingwavelabs#1923)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Chi <iskyzh@gmail.com>
  • Loading branch information
skyzh authored Apr 19, 2022
1 parent 82bca65 commit 7656f8a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 60 deletions.
1 change: 1 addition & 0 deletions e2e_test/v2/batch/tpch.slt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ include ../../tpch/insert_supplier.slt.part
include ../../tpch/insert_region.slt.part

include ../../batch/tpch/q1.slt.part
include ../../batch/tpch/q4.slt.part
include ../../batch/tpch/q5.slt.part
include ../../batch/tpch/q6.slt.part
include ../../batch/tpch/q7.slt.part
Expand Down
91 changes: 31 additions & 60 deletions src/frontend/test_runner/tests/testdata/tpch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -166,31 +166,6 @@
s_name,
p_partkey
limit 100;
logical_plan: |
LogicalLimit { limit: 100, offset: 0 }
LogicalProject { exprs: [$16, $12, $26, $1, $3, $13, $15, $17], expr_alias: [s_acctbal, s_name, n_name, p_partkey, p_mfgr, s_address, s_phone, s_comment] }
LogicalFilter { predicate: ($1 = $19) AND ($11 = $20) AND ($6 = 4:Int32) AND Like($5, '%TIN':Varchar) AND ($14 = $25) AND ($27 = $30) AND ($31 = 'AFRICA':Varchar) AND ($22 = $33) }
LogicalApply { type: LeftOuter }
LogicalJoin { type: Inner, on: always }
LogicalJoin { type: Inner, on: always }
LogicalJoin { type: Inner, on: always }
LogicalJoin { type: Inner, on: always }
LogicalScan { table: part, columns: [_row_id#0, p_partkey, p_name, p_mfgr, p_brand, p_type, p_size, p_container, p_retailprice, p_comment] }
LogicalScan { table: supplier, columns: [_row_id#0, s_suppkey, s_name, s_address, s_nationkey, s_phone, s_acctbal, s_comment] }
LogicalScan { table: partsupp, columns: [_row_id#0, ps_partkey, ps_suppkey, ps_availqty, ps_supplycost, ps_comment] }
LogicalScan { table: nation, columns: [_row_id#0, n_nationkey, n_name, n_regionkey, n_comment] }
LogicalScan { table: region, columns: [_row_id#0, r_regionkey, r_name, r_comment] }
LogicalProject { exprs: [$0], expr_alias: [ ] }
LogicalAgg { group_keys: [], agg_calls: [min($0)] }
LogicalProject { exprs: [$4], expr_alias: [ ] }
LogicalFilter { predicate: (CorrelatedInputRef { index: 1, depth: 1 } = $1) AND ($7 = $2) AND ($10 = $15) AND ($17 = $20) AND ($21 = 'AFRICA':Varchar) }
LogicalJoin { type: Inner, on: always }
LogicalJoin { type: Inner, on: always }
LogicalJoin { type: Inner, on: always }
LogicalScan { table: partsupp, columns: [_row_id#0, ps_partkey, ps_suppkey, ps_availqty, ps_supplycost, ps_comment] }
LogicalScan { table: supplier, columns: [_row_id#0, s_suppkey, s_name, s_address, s_nationkey, s_phone, s_acctbal, s_comment] }
LogicalScan { table: nation, columns: [_row_id#0, n_nationkey, n_name, n_regionkey, n_comment] }
LogicalScan { table: region, columns: [_row_id#0, r_regionkey, r_name, r_comment] }
optimized_logical_plan: |
LogicalLimit { limit: 100, offset: 0 }
LogicalProject { exprs: [$5, $2, $8, $0, $1, $3, $4, $6], expr_alias: [s_acctbal, s_name, n_name, p_partkey, p_mfgr, s_address, s_phone, s_comment] }
Expand Down Expand Up @@ -316,27 +291,37 @@
o_orderpriority
order by
o_orderpriority;
logical_plan: |
LogicalProject { exprs: [$0, $1], expr_alias: [o_orderpriority, order_count] }
LogicalAgg { group_keys: [0], agg_calls: [count] }
LogicalProject { exprs: [$6], expr_alias: [ ] }
LogicalFilter { predicate: ($5 >= '1997-07-01':Varchar::Date) AND ($5 < ('1997-07-01':Varchar::Date + '3 mons 00:00:00':Interval)) }
LogicalApply { type: LeftSemi }
LogicalScan { table: orders, columns: [_row_id#0, o_orderkey, o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment] }
LogicalProject { exprs: [$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16], expr_alias: [l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment] }
LogicalFilter { predicate: ($1 = CorrelatedInputRef { index: 1, depth: 1 }) AND ($12 < $13) }
LogicalScan { table: lineitem, columns: [_row_id#0, l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment] }
optimized_logical_plan: |
LogicalProject { exprs: [$0, $1], expr_alias: [o_orderpriority, order_count] }
LogicalAgg { group_keys: [0], agg_calls: [count] }
LogicalProject { exprs: [$1], expr_alias: [ ] }
LogicalJoin { type: LeftSemi, on: ($2 = $0) }
LogicalProject { exprs: [$0, $2], expr_alias: [ , ] }
LogicalFilter { predicate: ($1 >= '1997-07-01':Varchar::Date) AND ($1 < ('1997-07-01':Varchar::Date + '3 mons 00:00:00':Interval)) }
LogicalScan { table: orders, columns: [o_orderkey, o_orderdate, o_orderpriority] }
LogicalProject { exprs: [$0], expr_alias: [ ] }
LogicalFilter { predicate: ($1 < $2) }
LogicalScan { table: lineitem, columns: [l_orderkey, l_commitdate, l_receiptdate] }
batch_plan: |
BatchExchange { order: [$0 ASC], dist: Single }
BatchSort { order: [$0 ASC] }
BatchProject { exprs: [$0, $1], expr_alias: [o_orderpriority, order_count] }
BatchHashAgg { group_keys: [$0], aggs: [count] }
BatchProject { exprs: [$1], expr_alias: [ ] }
BatchExchange { order: [], dist: HashShard([1]) }
BatchHashJoin { type: LeftSemi, predicate: $0 = $2 }
BatchProject { exprs: [$0, $2], expr_alias: [ , ] }
BatchExchange { order: [], dist: HashShard([0]) }
BatchFilter { predicate: ($1 >= '1997-07-01':Varchar::Date) AND ($1 < ('1997-07-01':Varchar::Date + '3 mons 00:00:00':Interval)) }
BatchScan { table: orders, columns: [o_orderkey, o_orderdate, o_orderpriority] }
BatchProject { exprs: [$0], expr_alias: [ ] }
BatchExchange { order: [], dist: HashShard([0]) }
BatchFilter { predicate: ($1 < $2) }
BatchScan { table: lineitem, columns: [l_orderkey, l_commitdate, l_receiptdate] }
stream_plan: |
StreamMaterialize { columns: [o_orderpriority, order_count], pk_columns: [o_orderpriority] }
StreamProject { exprs: [$0, $2], expr_alias: [o_orderpriority, order_count] }
StreamHashAgg { group_keys: [$0], aggs: [count, count] }
StreamProject { exprs: [$1, $2, $4], expr_alias: [ , , ] }
StreamExchange { dist: HashShard([1]) }
StreamHashJoin { type: LeftSemi, predicate: $0 = $3 }
StreamProject { exprs: [$0, $2, $3], expr_alias: [ , , ] }
StreamExchange { dist: HashShard([0]) }
StreamFilter { predicate: ($1 >= '1997-07-01':Varchar::Date) AND ($1 < ('1997-07-01':Varchar::Date + '3 mons 00:00:00':Interval)) }
StreamTableScan { table: orders, columns: [o_orderkey, o_orderdate, o_orderpriority, _row_id#0], pk_indices: [3] }
StreamProject { exprs: [$0, $3], expr_alias: [ , ] }
StreamExchange { dist: HashShard([0]) }
StreamFilter { predicate: ($1 < $2) }
StreamTableScan { table: lineitem, columns: [l_orderkey, l_commitdate, l_receiptdate, _row_id#0], pk_indices: [3] }
- id: tpch_q5
before:
- create_tables
Expand Down Expand Up @@ -985,20 +970,6 @@
where
l_partkey = p_partkey
);
logical_plan: |
LogicalProject { exprs: [RoundDigit(($0 / 7.0:Decimal), 16:Int32)], expr_alias: [avg_yearly] }
LogicalAgg { group_keys: [], agg_calls: [sum($0)] }
LogicalProject { exprs: [$6], expr_alias: [ ] }
LogicalFilter { predicate: ($18 = $2) AND ($21 = 'Brand#13':Varchar) AND ($24 = 'JUMBO PKG':Varchar) AND ($5 < $27) }
LogicalApply { type: LeftOuter }
LogicalJoin { type: Inner, on: always }
LogicalScan { table: lineitem, columns: [_row_id#0, l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment] }
LogicalScan { table: part, columns: [_row_id#0, p_partkey, p_name, p_mfgr, p_brand, p_type, p_size, p_container, p_retailprice, p_comment] }
LogicalProject { exprs: [(0.2:Decimal * ($0 / $1))], expr_alias: [ ] }
LogicalAgg { group_keys: [], agg_calls: [sum($0), count($0)] }
LogicalProject { exprs: [$5], expr_alias: [ ] }
LogicalFilter { predicate: ($2 = CorrelatedInputRef { index: 18, depth: 1 }) }
LogicalScan { table: lineitem, columns: [_row_id#0, l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment] }
optimized_logical_plan: |
LogicalProject { exprs: [RoundDigit(($0 / 7.0:Decimal), 16:Int32)], expr_alias: [avg_yearly] }
LogicalAgg { group_keys: [], agg_calls: [sum($0)] }
Expand Down

0 comments on commit 7656f8a

Please sign in to comment.