Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit a6d9851

Browse files
authored
Fix: Fix for physical when budget is reached (#119)
Continue on executing physical rules when budget limit is reached. --------- Signed-off-by: AveryQi115 <[email protected]>
1 parent 1c557a4 commit a6d9851

File tree

2 files changed

+64
-67
lines changed

2 files changed

+64
-67
lines changed

optd-core/src/cascades/tasks/optimize_expression.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<T: RelNodeTyp> Task<T> for OptimizeExpressionTask {
5555
}
5656
// Skip transformation rules when budget is used
5757
if optimizer.ctx.budget_used && !rule.is_impl_rule() {
58-
break;
58+
continue;
5959
}
6060
if top_matches(rule.matcher(), expr.typ.clone(), expr.data.clone()) {
6161
tasks.push(

optd-sqlplannertest/tests/tpch.planner.sql

+63-66
Original file line numberDiff line numberDiff line change
@@ -364,72 +364,69 @@ PhysicalLimit { skip: 0, fetch: 100 }
364364
│ └── SortOrder { order: Asc }
365365
│ └── #3
366366
└── PhysicalProjection { exprs: [ #5, #2, #8, #0, #1, #3, #4, #6 ] }
367-
└── PhysicalProjection { exprs: [ #0, #1, #2, #3, #4, #5, #6, #7, #8, #11, #12 ] }
368-
└── PhysicalProjection { exprs: [ #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #0, #11, #12 ] }
369-
└── PhysicalProjection { exprs: [ #0, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13 ] }
370-
└── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #9 ] }
371-
├── PhysicalFilter
372-
│ ├── cond:Eq
373-
│ │ ├── #1
374-
│ │ └── "AFRICA"
375-
│ └── PhysicalProjection { exprs: [ #0, #1 ] }
376-
│ └── PhysicalScan { table: region }
377-
└── PhysicalProjection { exprs: [ #0, #1, #2, #3, #5, #6, #7, #8, #10, #11, #12, #13 ] }
378-
└── PhysicalProjection { exprs: [ #3, #4, #5, #6, #7, #8, #9, #10, #11, #0, #1, #2, #12, #13 ] }
379-
└── PhysicalProjection { exprs: [ #0, #1, #2, #4, #5, #6, #7, #8, #9, #10, #11, #12, #13, #14 ] }
380-
└── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #4 ] }
381-
├── PhysicalScan { table: nation }
382-
└── PhysicalProjection { exprs: [ #0, #1, #5, #6, #7, #8, #9, #10, #3, #11, #12 ] }
383-
└── PhysicalProjection { exprs: [ #7, #8, #9, #10, #0, #1, #2, #3, #4, #5, #6, #11, #12 ] }
384-
└── PhysicalProjection { exprs: [ #0, #1, #2, #3, #4, #5, #6, #7, #8, #9, #10, #11, #12 ] }
385-
└── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #2 ] }
386-
├── PhysicalScan { table: supplier }
387-
└── PhysicalProjection { exprs: [ #0, #1, #3, #4, #5, #6 ] }
388-
└── PhysicalProjection { exprs: [ #0, #1, #4, #5, #6, #7, #8 ] }
389-
└── PhysicalNestedLoopJoin
390-
├── join_type: Inner
391-
├── cond:And
392-
│ ├── Eq
393-
│ │ ├── #0
394-
│ │ └── #8
395-
│ └── Eq
396-
│ ├── #6
397-
│ └── #7
398-
├── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ] }
399-
│ ├── PhysicalFilter
400-
│ │ ├── cond:And
401-
│ │ │ ├── Eq
402-
│ │ │ │ ├── #3
403-
│ │ │ │ └── 4
404-
│ │ │ └── Like { expr: #2, pattern: "%TIN", negated: false, case_insensitive: false }
405-
│ │ └── PhysicalProjection { exprs: [ #0, #2, #4, #5 ] }
406-
│ │ └── PhysicalScan { table: part }
407-
│ └── PhysicalProjection { exprs: [ #0, #1, #3 ] }
408-
│ └── PhysicalScan { table: partsupp }
409-
└── PhysicalProjection { exprs: [ #1, #0 ] }
410-
└── PhysicalAgg
411-
├── aggrs:Agg(Min)
412-
│ └── [ #1 ]
413-
├── groups: [ #0 ]
414-
└── PhysicalProjection { exprs: [ #0, #1 ] }
415-
└── PhysicalProjection { exprs: [ #0, #1, #4, #5 ] }
416-
└── PhysicalProjection { exprs: [ #0, #2, #4, #5, #6, #7 ] }
417-
└── PhysicalProjection { exprs: [ #0, #1, #3, #5, #6, #7, #8, #9 ] }
418-
└── PhysicalHashJoin { join_type: Inner, left_keys: [ #1 ], right_keys: [ #0 ] }
419-
├── PhysicalScan { table: partsupp }
420-
└── PhysicalHashJoin { join_type: Inner, left_keys: [ #1 ], right_keys: [ #0 ] }
421-
├── PhysicalProjection { exprs: [ #0, #3 ] }
422-
│ └── PhysicalScan { table: supplier }
423-
└── PhysicalHashJoin { join_type: Inner, left_keys: [ #1 ], right_keys: [ #0 ] }
424-
├── PhysicalProjection { exprs: [ #0, #2 ] }
425-
│ └── PhysicalScan { table: nation }
426-
└── PhysicalProjection { exprs: [ #0 ] }
427-
└── PhysicalFilter
428-
├── cond:Eq
429-
│ ├── #1
430-
│ └── "AFRICA"
431-
└── PhysicalProjection { exprs: [ #0, #1 ] }
432-
└── PhysicalScan { table: region }
367+
└── PhysicalNestedLoopJoin
368+
├── join_type: Inner
369+
├── cond:And
370+
│ ├── Eq
371+
│ │ ├── #0
372+
│ │ └── #10
373+
│ └── Eq
374+
│ ├── #7
375+
│ └── #9
376+
├── PhysicalProjection { exprs: [ #0, #1, #2, #3, #4, #5, #6, #7, #8 ] }
377+
│ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #9 ], right_keys: [ #0 ] }
378+
│ ├── PhysicalProjection { exprs: [ #0, #1, #2, #3, #5, #6, #7, #8, #10, #11 ] }
379+
│ │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #4 ], right_keys: [ #0 ] }
380+
│ │ ├── PhysicalProjection { exprs: [ #0, #1, #5, #6, #7, #8, #9, #10, #3 ] }
381+
│ │ │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #2 ], right_keys: [ #0 ] }
382+
│ │ │ ├── PhysicalProjection { exprs: [ #0, #1, #3, #4 ] }
383+
│ │ │ │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #0 ], right_keys: [ #0 ] }
384+
│ │ │ │ ├── PhysicalProjection { exprs: [ #0, #1 ] }
385+
│ │ │ │ │ └── PhysicalFilter
386+
│ │ │ │ │ ├── cond:And
387+
│ │ │ │ │ │ ├── Eq
388+
│ │ │ │ │ │ │ ├── #3
389+
│ │ │ │ │ │ │ └── 4
390+
│ │ │ │ │ │ └── Like { expr: #2, pattern: "%TIN", negated: false, case_insensitive: false }
391+
│ │ │ │ │ └── PhysicalProjection { exprs: [ #0, #2, #4, #5 ] }
392+
│ │ │ │ │ └── PhysicalScan { table: part }
393+
│ │ │ │ └── PhysicalProjection { exprs: [ #0, #1, #3 ] }
394+
│ │ │ │ └── PhysicalScan { table: partsupp }
395+
│ │ │ └── PhysicalProjection { exprs: [ #0, #1, #2, #3, #4, #5, #6 ] }
396+
│ │ │ └── PhysicalScan { table: supplier }
397+
│ │ └── PhysicalProjection { exprs: [ #0, #1, #2 ] }
398+
│ │ └── PhysicalScan { table: nation }
399+
│ └── PhysicalProjection { exprs: [ #0 ] }
400+
│ └── PhysicalFilter
401+
│ ├── cond:Eq
402+
│ │ ├── #1
403+
│ │ └── "AFRICA"
404+
│ └── PhysicalProjection { exprs: [ #0, #1 ] }
405+
│ └── PhysicalScan { table: region }
406+
└── PhysicalProjection { exprs: [ #1, #0 ] }
407+
└── PhysicalAgg
408+
├── aggrs:Agg(Min)
409+
│ └── [ #1 ]
410+
├── groups: [ #0 ]
411+
└── PhysicalProjection { exprs: [ #0, #1 ] }
412+
└── PhysicalHashJoin { join_type: Inner, left_keys: [ #2 ], right_keys: [ #0 ] }
413+
├── PhysicalProjection { exprs: [ #0, #1, #4 ] }
414+
│ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #2 ], right_keys: [ #0 ] }
415+
│ ├── PhysicalProjection { exprs: [ #0, #2, #4 ] }
416+
│ │ └── PhysicalHashJoin { join_type: Inner, left_keys: [ #1 ], right_keys: [ #0 ] }
417+
│ │ ├── PhysicalProjection { exprs: [ #0, #1, #3 ] }
418+
│ │ │ └── PhysicalScan { table: partsupp }
419+
│ │ └── PhysicalProjection { exprs: [ #0, #3 ] }
420+
│ │ └── PhysicalScan { table: supplier }
421+
│ └── PhysicalProjection { exprs: [ #0, #2 ] }
422+
│ └── PhysicalScan { table: nation }
423+
└── PhysicalProjection { exprs: [ #0 ] }
424+
└── PhysicalFilter
425+
├── cond:Eq
426+
│ ├── #1
427+
│ └── "AFRICA"
428+
└── PhysicalProjection { exprs: [ #0, #1 ] }
429+
└── PhysicalScan { table: region }
433430
*/
434431

435432
-- TPC-H Q3

0 commit comments

Comments
 (0)