-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(expr): add short circuit checker in
is_const
(#15758)
- Loading branch information
Showing
4 changed files
with
139 additions
and
3 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
src/frontend/planner_test/tests/testdata/input/short_circuit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# reference: <https://github.com/risingwavelabs/risingwave/issues/15724> | ||
|
||
- id: create_table | ||
sql: | | ||
create table t1 (c1 INT, c2 INT, c3 INT); | ||
expected_outputs: [] | ||
|
||
- id : short_circuit_or_pattern | ||
before: | ||
- create_table | ||
sql: | | ||
select true or 'abc'::int > 1; | ||
expected_outputs: | ||
- logical_plan | ||
- batch_plan | ||
|
||
- id : short_circuit_and_pattern | ||
before: | ||
- create_table | ||
sql: | | ||
select false and 'abc'::int > 1; | ||
expected_outputs: | ||
- logical_plan | ||
- batch_plan | ||
|
||
- id : short_circuit_or_pattern_with_table | ||
before: | ||
- create_table | ||
sql: | | ||
select true or 'abc'::int > c1 from t1; | ||
expected_outputs: | ||
- logical_plan | ||
- batch_plan | ||
|
||
- id : short_circuit_and_pattern_with_table | ||
before: | ||
- create_table | ||
sql: | | ||
select false and 'abc'::int > c1 from t1; | ||
expected_outputs: | ||
- logical_plan | ||
- batch_plan | ||
|
||
# should *not* be identified as const | ||
# otherwise the *semantic* will be inconsistent | ||
# ---- | ||
# - id : short_circuit_or_panic_pattern | ||
# before: | ||
# - create_table | ||
# sql: | | ||
# select 'abc'::int > c1 or true from t1; | ||
# expected_outputs: | ||
# - logical_plan | ||
# - batch_plan | ||
# ---- | ||
# - id : short_circuit_and_panic_pattern | ||
# before: | ||
# - create_table | ||
# sql: | | ||
# select 'abc'::int > c1 and false from t1; | ||
# expected_outputs: | ||
# - logical_plan | ||
# - batch_plan | ||
# ---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/frontend/planner_test/tests/testdata/output/short_circuit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# This file is automatically generated. See `src/frontend/planner_test/README.md` for more information. | ||
- id: create_table | ||
sql: | | ||
create table t1 (c1 INT, c2 INT, c3 INT); | ||
- id: short_circuit_or_pattern | ||
before: | ||
- create_table | ||
sql: | | ||
select true or 'abc'::int > 1; | ||
logical_plan: |- | ||
LogicalProject { exprs: [(true:Boolean OR ('abc':Varchar::Int32 > 1:Int32)) as $expr1] } | ||
└─LogicalValues { rows: [[]], schema: Schema { fields: [] } } | ||
batch_plan: 'BatchValues { rows: [[true:Boolean]] }' | ||
- id: short_circuit_and_pattern | ||
before: | ||
- create_table | ||
sql: | | ||
select false and 'abc'::int > 1; | ||
logical_plan: |- | ||
LogicalProject { exprs: [(false:Boolean AND ('abc':Varchar::Int32 > 1:Int32)) as $expr1] } | ||
└─LogicalValues { rows: [[]], schema: Schema { fields: [] } } | ||
batch_plan: 'BatchValues { rows: [[false:Boolean]] }' | ||
- id: short_circuit_or_pattern_with_table | ||
before: | ||
- create_table | ||
sql: | | ||
select true or 'abc'::int > c1 from t1; | ||
logical_plan: |- | ||
LogicalProject { exprs: [(true:Boolean OR ('abc':Varchar::Int32 > t1.c1)) as $expr1] } | ||
└─LogicalScan { table: t1, columns: [t1.c1, t1.c2, t1.c3, t1._row_id] } | ||
batch_plan: |- | ||
BatchExchange { order: [], dist: Single } | ||
└─BatchProject { exprs: [true:Boolean] } | ||
└─BatchScan { table: t1, columns: [t1.c1], distribution: SomeShard } | ||
- id: short_circuit_and_pattern_with_table | ||
before: | ||
- create_table | ||
sql: | | ||
select false and 'abc'::int > c1 from t1; | ||
logical_plan: |- | ||
LogicalProject { exprs: [(false:Boolean AND ('abc':Varchar::Int32 > t1.c1)) as $expr1] } | ||
└─LogicalScan { table: t1, columns: [t1.c1, t1.c2, t1.c3, t1._row_id] } | ||
batch_plan: |- | ||
BatchExchange { order: [], dist: Single } | ||
└─BatchProject { exprs: [false:Boolean] } | ||
└─BatchScan { table: t1, columns: [t1.c1], distribution: SomeShard } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters