Skip to content

Commit

Permalink
test: reproduce hash join planning issue (#265)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Chi Z <iskyzh@gmail.com>
  • Loading branch information
skyzh committed Dec 18, 2024
1 parent fa6817c commit 9dfc530
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
46 changes: 27 additions & 19 deletions optd-sqlplannertest/tests/joins/join_enumerate.planner.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,35 @@ select * from t2, t1, t3 where t1v1 = t2v1 and t1v2 = t3v2;
*/

-- Test whether the optimizer enumerates all 3-join orders. (It don't currently)
select * from t1, t2, t3 where t1v1 = t2v1 and t1v2 = t3v2;
select * from t1, (select * from t2, t3) where t1v1 = t2v1 and t1v2 = t3v2;

/*
(Join t2 (Join t1 t3))
(Join t2 (Join t3 t1))
(Join t3 (Join t1 t2))
(Join t3 (Join t2 t1))
(Join (Join t1 t2) t3)
(Join (Join t1 t3) t2)
(Join (Join t2 t1) t3)
(Join (Join t3 t1) t2)
(Join t2 (Join t1 t3))
(Join t2 (Join t3 t1))
(Join t3 (Join t1 t2))
(Join t3 (Join t2 t1))
(Join (Join t1 t2) t3)
(Join (Join t1 t3) t2)
(Join (Join t2 t1) t3)
(Join (Join t3 t1) t2)
(Join t1 (Join t2 t3))
(Join (Join t2 t3) t1)
(Join t1 (Join t2 t3))
(Join (Join t2 t3) t1)
LogicalProjection { exprs: [ #0, #1, #2, #3, #4, #5 ] }
└── LogicalFilter
├── cond:And
│ ├── Eq
│ │ ├── #0
│ │ └── #2
│ └── Eq
│ ├── #1
│ └── #4
└── LogicalJoin { join_type: Cross, cond: true }
├── LogicalScan { table: t1 }
└── LogicalProjection { exprs: [ #0, #1, #2, #3 ] }
└── LogicalJoin { join_type: Cross, cond: true }
├── LogicalScan { table: t2 }
└── LogicalScan { table: t3 }
PhysicalHashJoin { join_type: Inner, left_keys: [ #0, #1 ], right_keys: [ #0, #2 ] }
├── PhysicalScan { table: t1 }
└── PhysicalNestedLoopJoin { join_type: Cross, cond: true }
├── PhysicalScan { table: t2 }
└── PhysicalScan { table: t3 }
0 0 0 200 0 300
1 1 1 201 1 301
2 2 2 202 2 302
Expand Down
4 changes: 2 additions & 2 deletions optd-sqlplannertest/tests/joins/join_enumerate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
- explain:logical_join_orders
- execute
- sql: |
select * from t1, t2, t3 where t1v1 = t2v1 and t1v2 = t3v2;
select * from t1, (select * from t2, t3) where t1v1 = t2v1 and t1v2 = t3v2;
desc: Test whether the optimizer enumerates all 3-join orders. (It don't currently)
tasks:
- explain[disable_pruning]:logical_join_orders
- explain:logical_join_orders
- explain:logical_join_orders,logical_optd,physical_optd
- execute

0 comments on commit 9dfc530

Please sign in to comment.