diff --git a/optd-sqlplannertest/tests/subqueries/subquery_unnesting.planner.sql b/optd-sqlplannertest/tests/subqueries/subquery_unnesting.planner.sql index 5b3be1b7..e2d3ad69 100644 --- a/optd-sqlplannertest/tests/subqueries/subquery_unnesting.planner.sql +++ b/optd-sqlplannertest/tests/subqueries/subquery_unnesting.planner.sql @@ -62,36 +62,29 @@ LogicalProjection { exprs: [ #0, #1 ] } ├── LogicalAgg { exprs: [], groups: [ #0 ] } │ └── LogicalScan { table: t1 } └── LogicalScan { table: t2 } -PhysicalProjection { exprs: [ #0, #1 ], cost: {compute=4033080,io=4000}, stat: {row_cnt=10} } -└── PhysicalProjection { exprs: [ #0, #1, #2, #4 ], cost: {compute=4033050,io=4000}, stat: {row_cnt=10} } - └── PhysicalFilter - ├── cond:Gt - │ ├── #4 - │ └── 100(i64) - ├── cost: {compute=4033000,io=4000} - ├── stat: {row_cnt=10} - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=4030000,io=4000}, stat: {row_cnt=1000} } - ├── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalNestedLoopJoin - ├── join_type: LeftOuter - ├── cond:And - │ └── Eq - │ ├── #0 - │ └── #1 - ├── cost: {compute=4018000,io=3000} - ├── stat: {row_cnt=10000} - ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } - │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalAgg - ├── aggrs:Agg(Sum) - │ └── [ Cast { cast_to: Int64, child: #2 } ] - ├── groups: [ #0 ] - ├── cost: {compute=14000,io=2000} - ├── stat: {row_cnt=1000} - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=6000,io=2000}, stat: {row_cnt=1000} } - ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } - │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalScan { table: t2, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } +PhysicalProjection { exprs: [ #0, #1 ], cost: {compute=24100,io=4000}, stat: {row_cnt=10} } +└── PhysicalProjection { exprs: [ #3, #4, #0, #2 ], cost: {compute=24070,io=4000}, stat: {row_cnt=10} } + └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=24020,io=4000}, stat: {row_cnt=10} } + ├── PhysicalFilter + │ ├── cond:Gt + │ │ ├── #2 + │ │ └── 100(i64) + │ ├── cost: {compute=23000,io=3000} + │ ├── stat: {row_cnt=10} + │ └── PhysicalHashJoin { join_type: LeftOuter, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=20000,io=3000}, stat: {row_cnt=1000} } + │ ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } + │ │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + │ └── PhysicalAgg + │ ├── aggrs:Agg(Sum) + │ │ └── [ Cast { cast_to: Int64, child: #2 } ] + │ ├── groups: [ #0 ] + │ ├── cost: {compute=14000,io=2000} + │ ├── stat: {row_cnt=1000} + │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=6000,io=2000}, stat: {row_cnt=1000} } + │ ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } + │ │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + │ └── PhysicalScan { table: t2, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } */ -- Test whether the optimizer can unnest correlated subqueries with (scalar op group agg) @@ -168,53 +161,39 @@ LogicalProjection { exprs: [ #0, #1 ] } ├── LogicalAgg { exprs: [], groups: [ #0 ] } │ └── LogicalScan { table: t1 } └── LogicalScan { table: t2 } -PhysicalProjection { exprs: [ #0, #1 ], cost: {compute=44228080,io=5000}, stat: {row_cnt=10} } -└── PhysicalProjection { exprs: [ #0, #1, #2, #4 ], cost: {compute=44228050,io=5000}, stat: {row_cnt=10} } - └── PhysicalFilter - ├── cond:Gt - │ ├── #4 - │ └── 100(i64) - ├── cost: {compute=44228000,io=5000} - ├── stat: {row_cnt=10} - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=44225000,io=5000}, stat: {row_cnt=1000} } - ├── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalNestedLoopJoin - ├── join_type: LeftOuter - ├── cond:And - │ └── Eq - │ ├── #0 - │ └── #1 - ├── cost: {compute=44123000,io=4000} - ├── stat: {row_cnt=100000} - ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } - │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalAgg - ├── aggrs:Agg(Sum) - │ └── [ #2 ] - ├── groups: [ #0 ] - ├── cost: {compute=4119000,io=3000} - ├── stat: {row_cnt=10000} - └── PhysicalProjection { exprs: [ #0, #2, #3 ], cost: {compute=4059000,io=3000}, stat: {row_cnt=10000} } - └── PhysicalNestedLoopJoin - ├── join_type: LeftOuter - ├── cond:And - │ └── Eq - │ ├── #0 - │ └── #1 - ├── cost: {compute=4019000,io=3000} - ├── stat: {row_cnt=10000} - ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } - │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalAgg - ├── aggrs:Agg(Sum) - │ └── [ Cast { cast_to: Int64, child: #2 } ] - ├── groups: [ #0, #1 ] - ├── cost: {compute=15000,io=2000} - ├── stat: {row_cnt=1000} - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=6000,io=2000}, stat: {row_cnt=1000} } - ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } - │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalScan { table: t2, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } +PhysicalProjection { exprs: [ #0, #1 ], cost: {compute=41100,io=5000}, stat: {row_cnt=10} } +└── PhysicalProjection { exprs: [ #3, #4, #0, #2 ], cost: {compute=41070,io=5000}, stat: {row_cnt=10} } + └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=41020,io=5000}, stat: {row_cnt=10} } + ├── PhysicalFilter + │ ├── cond:Gt + │ │ ├── #2 + │ │ └── 100(i64) + │ ├── cost: {compute=40000,io=4000} + │ ├── stat: {row_cnt=10} + │ └── PhysicalHashJoin { join_type: LeftOuter, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=37000,io=4000}, stat: {row_cnt=1000} } + │ ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } + │ │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + │ └── PhysicalAgg + │ ├── aggrs:Agg(Sum) + │ │ └── [ #2 ] + │ ├── groups: [ #0 ] + │ ├── cost: {compute=31000,io=3000} + │ ├── stat: {row_cnt=1000} + │ └── PhysicalProjection { exprs: [ #0, #2, #3 ], cost: {compute=25000,io=3000}, stat: {row_cnt=1000} } + │ └── PhysicalHashJoin { join_type: LeftOuter, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=21000,io=3000}, stat: {row_cnt=1000} } + │ ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } + │ │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + │ └── PhysicalAgg + │ ├── aggrs:Agg(Sum) + │ │ └── [ Cast { cast_to: Int64, child: #2 } ] + │ ├── groups: [ #0, #1 ] + │ ├── cost: {compute=15000,io=2000} + │ ├── stat: {row_cnt=1000} + │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=6000,io=2000}, stat: {row_cnt=1000} } + │ ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } + │ │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + │ └── PhysicalScan { table: t2, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } */ -- Test whether the optimizer can unnest correlated subqueries with scalar agg in select list @@ -264,18 +243,11 @@ LogicalProjection { exprs: [ #0, #2 ] } ├── LogicalAgg { exprs: [], groups: [ #0 ] } │ └── LogicalScan { table: t1 } └── LogicalScan { table: t2 } -PhysicalProjection { exprs: [ #0, #3 ], cost: {compute=4038000,io=4000}, stat: {row_cnt=1000} } -└── PhysicalProjection { exprs: [ #0, #1, #2, #4 ], cost: {compute=4035000,io=4000}, stat: {row_cnt=1000} } - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=4030000,io=4000}, stat: {row_cnt=1000} } - ├── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalNestedLoopJoin - ├── join_type: LeftOuter - ├── cond:And - │ └── Eq - │ ├── #0 - │ └── #1 - ├── cost: {compute=4018000,io=3000} - ├── stat: {row_cnt=10000} +PhysicalProjection { exprs: [ #0, #3 ], cost: {compute=29000,io=4000}, stat: {row_cnt=1000} } +└── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=26000,io=4000}, stat: {row_cnt=1000} } + ├── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + └── PhysicalProjection { exprs: [ #0, #2 ], cost: {compute=23000,io=3000}, stat: {row_cnt=1000} } + └── PhysicalHashJoin { join_type: LeftOuter, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=20000,io=3000}, stat: {row_cnt=1000} } ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } └── PhysicalAgg @@ -359,37 +331,30 @@ LogicalProjection { exprs: [ #0, #1 ] } └── LogicalJoin { join_type: Inner, cond: true } ├── LogicalScan { table: t2 } └── LogicalScan { table: t3 } -PhysicalProjection { exprs: [ #0, #1 ], cost: {compute=4036080,io=5000}, stat: {row_cnt=10} } -└── PhysicalProjection { exprs: [ #0, #1, #2, #4 ], cost: {compute=4036050,io=5000}, stat: {row_cnt=10} } - └── PhysicalFilter - ├── cond:Gt - │ ├── #4 - │ └── 100(i64) - ├── cost: {compute=4036000,io=5000} - ├── stat: {row_cnt=10} - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=4033000,io=5000}, stat: {row_cnt=1000} } - ├── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalNestedLoopJoin - ├── join_type: LeftOuter - ├── cond:And - │ └── Eq - │ ├── #0 - │ └── #1 - ├── cost: {compute=4021000,io=4000} - ├── stat: {row_cnt=10000} - ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } - │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalAgg - ├── aggrs:Agg(Sum) - │ └── [ Cast { cast_to: Int64, child: #2 } ] - ├── groups: [ #0 ] - ├── cost: {compute=17000,io=3000} - ├── stat: {row_cnt=1000} - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=9000,io=3000}, stat: {row_cnt=1000} } - ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } - │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #1 ], right_keys: [ #0 ], cost: {compute=3000,io=2000}, stat: {row_cnt=1000} } - ├── PhysicalScan { table: t2, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } - └── PhysicalScan { table: t3, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } +PhysicalProjection { exprs: [ #0, #1 ], cost: {compute=27100,io=5000}, stat: {row_cnt=10} } +└── PhysicalProjection { exprs: [ #3, #4, #0, #2 ], cost: {compute=27070,io=5000}, stat: {row_cnt=10} } + └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=27020,io=5000}, stat: {row_cnt=10} } + ├── PhysicalFilter + │ ├── cond:Gt + │ │ ├── #2 + │ │ └── 100(i64) + │ ├── cost: {compute=26000,io=4000} + │ ├── stat: {row_cnt=10} + │ └── PhysicalHashJoin { join_type: LeftOuter, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=23000,io=4000}, stat: {row_cnt=1000} } + │ ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } + │ │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + │ └── PhysicalAgg + │ ├── aggrs:Agg(Sum) + │ │ └── [ Cast { cast_to: Int64, child: #2 } ] + │ ├── groups: [ #0 ] + │ ├── cost: {compute=17000,io=3000} + │ ├── stat: {row_cnt=1000} + │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ], cost: {compute=9000,io=3000}, stat: {row_cnt=1000} } + │ ├── PhysicalAgg { aggrs: [], groups: [ #0 ], cost: {compute=3000,io=1000}, stat: {row_cnt=1000} } + │ │ └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #1 ], right_keys: [ #0 ], cost: {compute=3000,io=2000}, stat: {row_cnt=1000} } + │ ├── PhysicalScan { table: t2, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + │ └── PhysicalScan { table: t3, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } + └── PhysicalScan { table: t1, cost: {compute=0,io=1000}, stat: {row_cnt=1000} } */ diff --git a/optd-sqlplannertest/tests/tpch/q16.planner.sql b/optd-sqlplannertest/tests/tpch/q16.planner.sql index ca5fdb66..9524f9ab 100644 --- a/optd-sqlplannertest/tests/tpch/q16.planner.sql +++ b/optd-sqlplannertest/tests/tpch/q16.planner.sql @@ -91,11 +91,7 @@ PhysicalSort │ ├── InList { expr: Cast { cast_to: Int64, child: #10 }, list: [ 49(i64), 14(i64), 23(i64), 45(i64), 19(i64), 3(i64), 36(i64), 9(i64) ], negated: false } │ └── Not │ └── [ #14 ] - └── PhysicalNestedLoopJoin - ├── join_type: LeftMark - ├── cond:Eq - │ ├── #1 - │ └── #14 + └── PhysicalHashJoin { join_type: LeftMark, left_keys: [ #1 ], right_keys: [ #0 ] } ├── PhysicalNestedLoopJoin { join_type: Inner, cond: true } │ ├── PhysicalScan { table: partsupp } │ └── PhysicalScan { table: part } diff --git a/optd-sqlplannertest/tests/tpch/q17.planner.sql b/optd-sqlplannertest/tests/tpch/q17.planner.sql index 1410e2e0..5b50a0a3 100644 --- a/optd-sqlplannertest/tests/tpch/q17.planner.sql +++ b/optd-sqlplannertest/tests/tpch/q17.planner.sql @@ -78,52 +78,48 @@ PhysicalProjection └── PhysicalNestedLoopJoin ├── join_type: Inner ├── cond:And - │ ├── Eq - │ │ ├── #16 - │ │ └── #1 - │ └── Lt - │ ├── Cast { cast_to: Decimal128(30, 15), child: #4 } - │ └── #26 - ├── PhysicalScan { table: lineitem } - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ] } - ├── PhysicalFilter - │ ├── cond:And - │ │ ├── Eq - │ │ │ ├── #3 - │ │ │ └── "Brand#13" - │ │ └── Eq - │ │ ├── #6 - │ │ └── "JUMBO PKG" - │ └── PhysicalScan { table: part } - └── PhysicalProjection - ├── exprs: - │ ┌── #0 - │ └── Cast - │ ├── cast_to: Decimal128(30, 15) - │ ├── child:Mul - │ │ ├── 0.2(float) - │ │ └── Cast { cast_to: Float64, child: #1 } + │ ├── Lt + │ │ ├── Cast { cast_to: Decimal128(30, 15), child: #4 } + │ │ └── #26 + │ └── Eq + │ ├── #16 + │ └── #25 + ├── PhysicalProjection { exprs: [ #9, #10, #11, #12, #13, #14, #15, #16, #17, #18, #19, #20, #21, #22, #23, #24, #0, #1, #2, #3, #4, #5, #6, #7, #8 ] } + │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #1 ] } + │ ├── PhysicalFilter + │ │ ├── cond:And + │ │ │ ├── Eq + │ │ │ │ ├── #3 + │ │ │ │ └── "Brand#13" + │ │ │ └── Eq + │ │ │ ├── #6 + │ │ │ └── "JUMBO PKG" + │ │ └── PhysicalScan { table: part } + │ └── PhysicalScan { table: lineitem } + └── PhysicalProjection + ├── exprs: + │ ┌── #0 + │ └── Cast + │ ├── cast_to: Decimal128(30, 15) + │ ├── child:Mul + │ │ ├── 0.2(float) + │ │ └── Cast { cast_to: Float64, child: #1 } - └── PhysicalProjection { exprs: [ #0, #2 ] } - └── PhysicalNestedLoopJoin - ├── join_type: LeftOuter - ├── cond:And - │ └── Eq - │ ├── #0 - │ └── #1 - ├── PhysicalAgg { aggrs: [], groups: [ #16 ] } - │ └── PhysicalNestedLoopJoin { join_type: Inner, cond: true } - │ ├── PhysicalScan { table: lineitem } - │ └── PhysicalScan { table: part } - └── PhysicalAgg - ├── aggrs:Agg(Avg) - │ └── [ #5 ] - ├── groups: [ #0 ] - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #1 ] } - ├── PhysicalAgg { aggrs: [], groups: [ #16 ] } - │ └── PhysicalNestedLoopJoin { join_type: Inner, cond: true } - │ ├── PhysicalScan { table: lineitem } - │ └── PhysicalScan { table: part } - └── PhysicalScan { table: lineitem } + └── PhysicalProjection { exprs: [ #0, #2 ] } + └── PhysicalHashJoin { join_type: LeftOuter, left_keys: [ #0 ], right_keys: [ #0 ] } + ├── PhysicalAgg { aggrs: [], groups: [ #16 ] } + │ └── PhysicalNestedLoopJoin { join_type: Inner, cond: true } + │ ├── PhysicalScan { table: lineitem } + │ └── PhysicalScan { table: part } + └── PhysicalAgg + ├── aggrs:Agg(Avg) + │ └── [ #5 ] + ├── groups: [ #0 ] + └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #1 ] } + ├── PhysicalAgg { aggrs: [], groups: [ #16 ] } + │ └── PhysicalNestedLoopJoin { join_type: Inner, cond: true } + │ ├── PhysicalScan { table: lineitem } + │ └── PhysicalScan { table: part } + └── PhysicalScan { table: lineitem } */ diff --git a/optd-sqlplannertest/tests/tpch/q2.planner.sql b/optd-sqlplannertest/tests/tpch/q2.planner.sql index 013ff9a4..3b99799e 100644 --- a/optd-sqlplannertest/tests/tpch/q2.planner.sql +++ b/optd-sqlplannertest/tests/tpch/q2.planner.sql @@ -262,12 +262,7 @@ PhysicalLimit { skip: 0(i64), fetch: 100(i64) } │ │ └── "AFRICA" │ └── PhysicalScan { table: region } └── PhysicalProjection { exprs: [ #0, #2 ] } - └── PhysicalNestedLoopJoin - ├── join_type: LeftOuter - ├── cond:And - │ └── Eq - │ ├── #0 - │ └── #1 + └── PhysicalHashJoin { join_type: LeftOuter, left_keys: [ #0 ], right_keys: [ #0 ] } ├── PhysicalAgg { aggrs: [], groups: [ #0 ] } │ └── PhysicalNestedLoopJoin { join_type: Inner, cond: true } │ ├── PhysicalNestedLoopJoin { join_type: Inner, cond: true } diff --git a/optd-sqlplannertest/tests/tpch/q20.planner.sql b/optd-sqlplannertest/tests/tpch/q20.planner.sql index 181ad0b3..a9d8b779 100644 --- a/optd-sqlplannertest/tests/tpch/q20.planner.sql +++ b/optd-sqlplannertest/tests/tpch/q20.planner.sql @@ -106,84 +106,71 @@ PhysicalSort │ └── Eq │ ├── #8 │ └── "IRAQ" - └── PhysicalNestedLoopJoin - ├── join_type: LeftMark - ├── cond:Eq - │ ├── #0 - │ └── #11 + └── PhysicalHashJoin { join_type: LeftMark, left_keys: [ #0 ], right_keys: [ #0 ] } ├── PhysicalNestedLoopJoin { join_type: Inner, cond: true } │ ├── PhysicalScan { table: supplier } │ └── PhysicalScan { table: nation } └── PhysicalProjection { exprs: [ #1 ] } - └── PhysicalProjection { exprs: [ #3, #4, #5, #6, #7, #8, #0, #1, #2 ] } - └── PhysicalFilter - ├── cond:And - │ ├── #8 - │ └── Gt - │ ├── Cast { cast_to: Float64, child: #5 } - │ └── #2 - └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0, #1 ], right_keys: [ #0, #1 ] } - ├── PhysicalProjection - │ ├── exprs: - │ │ ┌── #0 - │ │ ├── #1 - │ │ └── Mul - │ │ ├── 0.5(float) - │ │ └── Cast { cast_to: Float64, child: #2 } - │ └── PhysicalProjection { exprs: [ #0, #1, #4 ] } - │ └── PhysicalNestedLoopJoin - │ ├── join_type: LeftOuter - │ ├── cond:And - │ │ ├── Eq - │ │ │ ├── #0 - │ │ │ └── #2 - │ │ └── Eq - │ │ ├── #1 - │ │ └── #3 - │ ├── PhysicalAgg { aggrs: [], groups: [ #0, #1 ] } - │ │ └── PhysicalNestedLoopJoin - │ │ ├── join_type: LeftMark - │ │ ├── cond:Eq - │ │ │ ├── #0 - │ │ │ └── #5 - │ │ ├── PhysicalScan { table: partsupp } - │ │ └── PhysicalProjection { exprs: [ #0 ] } - │ │ └── PhysicalFilter { cond: Like { expr: #1, pattern: "indian%", negated: false, case_insensitive: false } } - │ │ └── PhysicalScan { table: part } - │ └── PhysicalAgg - │ ├── aggrs:Agg(Sum) - │ │ └── [ #6 ] - │ ├── groups: [ #0, #1 ] - │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0, #1 ], right_keys: [ #1, #2 ] } - │ ├── PhysicalAgg { aggrs: [], groups: [ #0, #1 ] } - │ │ └── PhysicalNestedLoopJoin - │ │ ├── join_type: LeftMark - │ │ ├── cond:Eq - │ │ │ ├── #0 - │ │ │ └── #5 - │ │ ├── PhysicalScan { table: partsupp } - │ │ └── PhysicalProjection { exprs: [ #0 ] } - │ │ └── PhysicalFilter { cond: Like { expr: #1, pattern: "indian%", negated: false, case_insensitive: false } } - │ │ └── PhysicalScan { table: part } - │ └── PhysicalFilter - │ ├── cond:And - │ │ ├── Geq - │ │ │ ├── #10 - │ │ │ └── Cast { cast_to: Date32, child: "1996-01-01" } - │ │ └── Lt - │ │ ├── #10 - │ │ └── Add - │ │ ├── Cast { cast_to: Date32, child: "1996-01-01" } - │ │ └── INTERVAL_MONTH_DAY_NANO (12, 0, 0) - │ └── PhysicalScan { table: lineitem } - └── PhysicalNestedLoopJoin - ├── join_type: LeftMark - ├── cond:Eq - │ ├── #0 - │ └── #5 - ├── PhysicalScan { table: partsupp } - └── PhysicalProjection { exprs: [ #0 ] } - └── PhysicalFilter { cond: Like { expr: #1, pattern: "indian%", negated: false, case_insensitive: false } } - └── PhysicalScan { table: part } + └── PhysicalNestedLoopJoin + ├── join_type: Inner + ├── cond:And + │ ├── Gt + │ │ ├── Cast { cast_to: Float64, child: #2 } + │ │ └── #8 + │ ├── Eq + │ │ ├── #0 + │ │ └── #6 + │ └── Eq + │ ├── #1 + │ └── #7 + ├── PhysicalFilter { cond: #5 } + │ └── PhysicalHashJoin { join_type: LeftMark, left_keys: [ #0 ], right_keys: [ #0 ] } + │ ├── PhysicalScan { table: partsupp } + │ └── PhysicalProjection { exprs: [ #0 ] } + │ └── PhysicalFilter { cond: Like { expr: #1, pattern: "indian%", negated: false, case_insensitive: false } } + │ └── PhysicalScan { table: part } + └── PhysicalProjection + ├── exprs: + │ ┌── #0 + │ ├── #1 + │ └── Mul + │ ├── 0.5(float) + │ └── Cast { cast_to: Float64, child: #2 } + └── PhysicalProjection { exprs: [ #0, #1, #4 ] } + └── PhysicalHashJoin { join_type: LeftOuter, left_keys: [ #0, #1 ], right_keys: [ #0, #1 ] } + ├── PhysicalAgg { aggrs: [], groups: [ #0, #1 ] } + │ └── PhysicalHashJoin { join_type: LeftMark, left_keys: [ #0 ], right_keys: [ #0 ] } + │ ├── PhysicalScan { table: partsupp } + │ └── PhysicalProjection { exprs: [ #0 ] } + │ └── PhysicalFilter { cond: Like { expr: #1, pattern: "indian%", negated: false, case_insensitive: false } } + │ └── PhysicalScan { table: part } + └── PhysicalAgg + ├── aggrs:Agg(Sum) + │ └── [ #6 ] + ├── groups: [ #0, #1 ] + └── PhysicalFilter + ├── cond:And + │ ├── Eq + │ │ ├── #3 + │ │ └── #0 + │ ├── Eq + │ │ ├── #4 + │ │ └── #1 + │ ├── Geq + │ │ ├── #12 + │ │ └── Cast { cast_to: Date32, child: "1996-01-01" } + │ └── Lt + │ ├── #12 + │ └── Add + │ ├── Cast { cast_to: Date32, child: "1996-01-01" } + │ └── INTERVAL_MONTH_DAY_NANO (12, 0, 0) + └── PhysicalNestedLoopJoin { join_type: Inner, cond: true } + ├── PhysicalAgg { aggrs: [], groups: [ #0, #1 ] } + │ └── PhysicalHashJoin { join_type: LeftMark, left_keys: [ #0 ], right_keys: [ #0 ] } + │ ├── PhysicalScan { table: partsupp } + │ └── PhysicalProjection { exprs: [ #0 ] } + │ └── PhysicalFilter { cond: Like { expr: #1, pattern: "indian%", negated: false, case_insensitive: false } } + │ └── PhysicalScan { table: part } + └── PhysicalScan { table: lineitem } */ diff --git a/optd-sqlplannertest/tests/tpch/q22.planner.sql b/optd-sqlplannertest/tests/tpch/q22.planner.sql index 01a22608..d80ea330 100644 --- a/optd-sqlplannertest/tests/tpch/q22.planner.sql +++ b/optd-sqlplannertest/tests/tpch/q22.planner.sql @@ -121,12 +121,7 @@ PhysicalSort │ │ └── #8 │ └── Not │ └── [ #9 ] - └── PhysicalNestedLoopJoin - ├── join_type: LeftMark - ├── cond:And - │ └── Eq - │ ├── #0 - │ └── #9 + └── PhysicalHashJoin { join_type: LeftMark, left_keys: [ #0 ], right_keys: [ #0 ] } ├── PhysicalNestedLoopJoin { join_type: Inner, cond: true } │ ├── PhysicalScan { table: customer } │ └── PhysicalAgg diff --git a/optd-sqlplannertest/tests/tpch/q4.planner.sql b/optd-sqlplannertest/tests/tpch/q4.planner.sql index 99bc78dc..27655428 100644 --- a/optd-sqlplannertest/tests/tpch/q4.planner.sql +++ b/optd-sqlplannertest/tests/tpch/q4.planner.sql @@ -71,12 +71,7 @@ PhysicalSort │ │ ├── Cast { cast_to: Date32, child: "1993-07-01" } │ │ └── INTERVAL_MONTH_DAY_NANO (3, 0, 0) │ └── #9 - └── PhysicalNestedLoopJoin - ├── join_type: LeftMark - ├── cond:And - │ └── Eq - │ ├── #0 - │ └── #9 + └── PhysicalHashJoin { join_type: LeftMark, left_keys: [ #0 ], right_keys: [ #0 ] } ├── PhysicalScan { table: orders } └── PhysicalProjection { exprs: [ #16, #0, #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13, #14, #15 ] } └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ] }