Skip to content

Commit

Permalink
refactor: improve Display for LogicalScan (#6906)
Browse files Browse the repository at this point in the history
To be less verbose & more consistent


Approved-By: BugenZhao

Co-Authored-By: xxchan <[email protected]>
  • Loading branch information
xxchan authored Dec 14, 2022
1 parent 18c880b commit 87279ad
Show file tree
Hide file tree
Showing 11 changed files with 139 additions and 120 deletions.
5 changes: 4 additions & 1 deletion ci/scripts/pr.env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export RUN_COMPACTION=0;
export RUN_META_BACKUP=0;

if [[ -n "$CHANGED" ]]; then
echo "Changes to Sqlsmith source files detected.";
echo "origin/main SHA: $(git rev-parse origin/main)";
echo "Changes to Sqlsmith source files detected:";
echo "$CHANGED";

export RUN_SQLSMITH=1;
export SQLSMITH_COUNT=100;
echo "Enabled Sqlsmith tests.";
Expand Down
2 changes: 2 additions & 0 deletions ci/scripts/run-unit-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ set -euo pipefail
echo "+++ Run unit tests with coverage"
# use tee to disable progress bar
NEXTEST_PROFILE=ci cargo llvm-cov nextest --lcov --output-path lcov.info --features failpoints,sync_point 2> >(tee);

if [[ "$RUN_SQLSMITH" -eq "1" ]]; then
echo "+++ Run sqlsmith tests"
NEXTEST_PROFILE=ci cargo nextest run run_sqlsmith_on_frontend --features "failpoints sync_point enable_sqlsmith_unit_test" 2> >(tee);
fi

Expand Down
12 changes: 6 additions & 6 deletions src/frontend/planner_test/tests/testdata/column_pruning.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
└─LogicalFilter { predicate: (t.v2 > 2:Int32) }
└─LogicalScan { table: t, columns: [t.v1, t.v2, t.v3, t._row_id] }
optimized_logical_plan: |
LogicalScan { table: t, output_columns: [t.v1], required_columns: [v1, v2], predicate: (t.v2 > 2:Int32) }
LogicalScan { table: t, output_columns: [t.v1], required_columns: [t.v1, t.v2], predicate: (t.v2 > 2:Int32) }
- name: join
sql: |
create table t1 (v1 int, v2 int, v3 int);
Expand All @@ -43,7 +43,7 @@
└─LogicalScan { table: t, columns: [t.v1, t.v2, t.v3, t._row_id] }
optimized_logical_plan: |
LogicalAgg { aggs: [count(t.v1)] }
└─LogicalScan { table: t, output_columns: [t.v1], required_columns: [v1, v2], predicate: (t.v2 > 2:Int32) }
└─LogicalScan { table: t, output_columns: [t.v1], required_columns: [t.v1, t.v2], predicate: (t.v2 > 2:Int32) }
- name: top n
sql: |
create table t (v1 int, v2 int, v3 int);
Expand Down Expand Up @@ -77,7 +77,7 @@
└─LogicalScan { table: t, columns: [t.v1, t.v2, t.v3, t._row_id] }
optimized_logical_plan: |
LogicalProject { exprs: [1:Int32] }
└─LogicalScan { table: t, output_columns: [], required_columns: [v2], predicate: (t.v2 > 1:Int32) }
└─LogicalScan { table: t, output_columns: [], required_columns: [t.v2], predicate: (t.v2 > 1:Int32) }
- name: constant agg
sql: |
create table t (v1 bigint, v2 double precision, v3 int);
Expand All @@ -104,7 +104,7 @@
optimized_logical_plan: |
LogicalAgg { aggs: [count(1:Int32)] }
└─LogicalProject { exprs: [1:Int32] }
└─LogicalScan { table: t, output_columns: [], required_columns: [v2], predicate: (t.v2 > 1:Int32) }
└─LogicalScan { table: t, output_columns: [], required_columns: [t.v2], predicate: (t.v2 > 1:Int32) }
- name: join + filter
sql: |
create table t1 (v1 int, v2 int, v3 int);
Expand All @@ -118,7 +118,7 @@
└─LogicalScan { table: t2, columns: [t2.v1, t2.v2, t2.v3, t2._row_id] }
optimized_logical_plan: |
LogicalJoin { type: Inner, on: (t1.v2 = t2.v2), output: [t1.v1, t2.v1] }
├─LogicalScan { table: t1, output_columns: [t1.v1, t1.v2], required_columns: [v1, v2, v3], predicate: (t1.v3 < 1:Int32) }
├─LogicalScan { table: t1, output_columns: [t1.v1, t1.v2], required_columns: [t1.v1, t1.v2, t1.v3], predicate: (t1.v3 < 1:Int32) }
└─LogicalScan { table: t2, columns: [t2.v1, t2.v2] }
- name: mixed
sql: |
Expand All @@ -133,7 +133,7 @@
optimized_logical_plan: |
LogicalAgg { aggs: [count(1:Int32), count(t.v1)] }
└─LogicalProject { exprs: [1:Int32, t.v1] }
└─LogicalScan { table: t, output_columns: [t.v1], required_columns: [v1, v2], predicate: (t.v2 > 1:Int32) }
└─LogicalScan { table: t, output_columns: [t.v1], required_columns: [t.v1, t.v2], predicate: (t.v2 > 1:Int32) }
- name: hop window, time_col not selected
sql: |
create table t1 (a int, b int, created_at timestamp);
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/planner_test/tests/testdata/join.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@
optimized_logical_plan: |
LogicalJoin { type: Inner, on: (t1.v2 = t3.v1), output: all }
├─LogicalScan { table: t1, columns: [t1.v1, t1.v2] }
└─LogicalScan { table: t3, output_columns: [t3.v1, t3.v2], required_columns: [v1, v2], predicate: (t3.v1 > 1:Int32) }
└─LogicalScan { table: t3, columns: [t3.v1, t3.v2], predicate: (t3.v1 > 1:Int32) }
batch_local_plan: |
BatchLookupJoin { type: Inner, predicate: t1.v2 = t3.v1 AND (t3.v1 > 1:Int32), output: all }
└─BatchExchange { order: [], dist: Single }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
optimized_logical_plan: |
LogicalProject { exprs: [t.x, t.y] }
└─LogicalTopN { order: "[t.x ASC]", limit: 2, offset: 0, group_key: [1] }
└─LogicalScan { table: t, output_columns: [t.x, t.y, t._row_id], required_columns: [x, y, _row_id], predicate: (t.x > t.y) }
└─LogicalScan { table: t, columns: [t.x, t.y, t._row_id], predicate: (t.x > t.y) }
batch_plan: |
BatchExchange { order: [], dist: Single }
└─BatchProject { exprs: [t.x, t.y] }
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/planner_test/tests/testdata/pk_derive.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
where
v3 = 'world' or v3 = 'hello';
optimized_logical_plan: |
LogicalScan { table: mv, output_columns: [mv.v1], required_columns: [v1, v3], predicate: ((mv.v3 = 'world':Varchar) OR (mv.v3 = 'hello':Varchar)) }
LogicalScan { table: mv, output_columns: [mv.v1], required_columns: [mv.v1, mv.v3], predicate: ((mv.v3 = 'world':Varchar) OR (mv.v3 = 'hello':Varchar)) }
stream_plan: |
StreamMaterialize { columns: [v1, mv.v2(hidden), mv.v3(hidden)], pk_columns: [v1, mv.v2, mv.v3] }
└─StreamFilter { predicate: ((mv.v3 = 'world':Varchar) OR (mv.v3 = 'hello':Varchar)) }
Expand Down
20 changes: 10 additions & 10 deletions src/frontend/planner_test/tests/testdata/predicate_pushdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@
└─LogicalScan { table: t2, columns: [t2.v1, t2.v2, t2.v3, t2._row_id] }
optimized_logical_plan: |
LogicalUnion { all: true }
├─LogicalScan { table: t1, output_columns: [t1.v1, t1.v2, t1.v3], required_columns: [v1, v2, v3], predicate: (t1.v1 = 10:Int32) AND (t1.v2 = 20:Int32) AND (t1.v3 = 30:Int32) }
└─LogicalScan { table: t2, output_columns: [t2.v1, t2.v2, t2.v3], required_columns: [v1, v2, v3], predicate: (t2.v1 = 10:Int32) AND (t2.v2 = 20:Int32) AND (t2.v3 = 30:Int32) }
├─LogicalScan { table: t1, columns: [t1.v1, t1.v2, t1.v3], predicate: (t1.v1 = 10:Int32) AND (t1.v2 = 20:Int32) AND (t1.v3 = 30:Int32) }
└─LogicalScan { table: t2, columns: [t2.v1, t2.v2, t2.v3], predicate: (t2.v1 = 10:Int32) AND (t2.v2 = 20:Int32) AND (t2.v3 = 30:Int32) }
- name: filter project transpose
sql: |
create table t(v1 int, v2 int, v3 int, v4 int, ts date);
Expand All @@ -87,7 +87,7 @@
└─LogicalScan { table: t, columns: [t.v1, t.v2, t.v3, t.v4, t.ts, t._row_id] }
optimized_logical_plan: |
LogicalProject { exprs: [t.v1, t.v2, t.v3, t.v4, (t.v1 + t.v2), (t.v3 * t.v4)] }
└─LogicalScan { table: t, output_columns: [t.v1, t.v2, t.v3, t.v4], required_columns: [v1, v2, v3, v4], predicate: ((t.v1 + t.v2) > 10:Int32) AND (t.v1 = 10:Int32) AND (t.v2 = 20:Int32) AND (t.v3 = 30:Int32) AND ((t.v1 + t.v2) > (t.v3 * t.v4)) AND ((t.v1 + t.v2) > t.v1) }
└─LogicalScan { table: t, columns: [t.v1, t.v2, t.v3, t.v4], predicate: ((t.v1 + t.v2) > 10:Int32) AND (t.v1 = 10:Int32) AND (t.v2 = 20:Int32) AND (t.v3 = 30:Int32) AND ((t.v1 + t.v2) > (t.v3 * t.v4)) AND ((t.v1 + t.v2) > t.v1) }
- name: filter agg transpose
sql: |
create table t(v1 int, v2 int, v3 int, v4 int, ts date);
Expand All @@ -103,7 +103,7 @@
LogicalFilter { predicate: (count > t.v1) AND (count > count(1:Int32)) }
└─LogicalAgg { group_key: [t.v1, t.v2, t.v3], aggs: [count, count(1:Int32)] }
└─LogicalProject { exprs: [t.v1, t.v2, t.v3, 1:Int32] }
└─LogicalScan { table: t, output_columns: [t.v1, t.v2, t.v3], required_columns: [v1, v2, v3], predicate: (t.v1 = 10:Int32) AND (t.v2 = 20:Int32) AND (t.v3 = 30:Int32) AND (t.v2 > t.v3) }
└─LogicalScan { table: t, columns: [t.v1, t.v2, t.v3], predicate: (t.v1 = 10:Int32) AND (t.v2 = 20:Int32) AND (t.v3 = 30:Int32) AND (t.v2 > t.v3) }
- name: filter project set transpose
sql: |
create table t(v1 int, v2 int, v3 int, arr int[]);
Expand Down Expand Up @@ -133,8 +133,8 @@
└─LogicalScan { table: t2, columns: [t2.v3, t2.v4, t2._row_id] }
optimized_logical_plan: |
LogicalJoin { type: Inner, on: true, output: all }
├─LogicalScan { table: t1, output_columns: [t1.v1, t1.v2], required_columns: [v1, v2], predicate: IsNull(t1.v1) AND IsNull(t1.v2) }
└─LogicalScan { table: t2, output_columns: [t2.v3, t2.v4], required_columns: [v3, v4], predicate: IsNull(t2.v3) AND IsNull(t2.v4) }
├─LogicalScan { table: t1, columns: [t1.v1, t1.v2], predicate: IsNull(t1.v1) AND IsNull(t1.v2) }
└─LogicalScan { table: t2, columns: [t2.v3, t2.v4], predicate: IsNull(t2.v3) AND IsNull(t2.v4) }
- name: filter left join transpose
sql: |
create table t1(v1 int, v2 int);
Expand All @@ -150,7 +150,7 @@
optimized_logical_plan: |
LogicalFilter { predicate: IsNull(t2.v3) AND IsNull(t2.v4) }
└─LogicalJoin { type: LeftOuter, on: true, output: all }
├─LogicalScan { table: t1, output_columns: [t1.v1, t1.v2], required_columns: [v1, v2], predicate: IsNull(t1.v1) AND IsNull(t1.v2) }
├─LogicalScan { table: t1, columns: [t1.v1, t1.v2], predicate: IsNull(t1.v1) AND IsNull(t1.v2) }
└─LogicalScan { table: t2, columns: [t2.v3, t2.v4] }
- name: filter right join transpose
sql: |
Expand All @@ -167,7 +167,7 @@
optimized_logical_plan: |
LogicalFilter { predicate: IsNull(t1.v1) AND IsNull(t1.v2) }
└─LogicalJoin { type: LeftOuter, on: true, output: [t1.v1, t1.v2, t2.v3, t2.v4] }
├─LogicalScan { table: t2, output_columns: [t2.v3, t2.v4], required_columns: [v3, v4], predicate: IsNull(t2.v3) AND IsNull(t2.v4) }
├─LogicalScan { table: t2, columns: [t2.v3, t2.v4], predicate: IsNull(t2.v3) AND IsNull(t2.v4) }
└─LogicalScan { table: t1, columns: [t1.v1, t1.v2] }
- name: filter full outer join transpose
sql: |
Expand Down Expand Up @@ -201,7 +201,7 @@
└─LogicalScan { table: t2, columns: [t2.v1, t2.v2, t2._row_id] }
optimized_logical_plan: |
LogicalJoin { type: LeftSemi, on: true, output: all }
├─LogicalScan { table: t1, output_columns: [t1.v1, t1.v2], required_columns: [v1, v2], predicate: IsNull(t1.v1) AND IsNull(t1.v2) }
├─LogicalScan { table: t1, columns: [t1.v1, t1.v2], predicate: IsNull(t1.v1) AND IsNull(t1.v2) }
└─LogicalScan { table: t2, columns: [] }
- name: filter anti join transpose
sql: |
Expand All @@ -218,5 +218,5 @@
└─LogicalScan { table: t2, columns: [t2.v1, t2.v2, t2._row_id] }
optimized_logical_plan: |
LogicalJoin { type: LeftAnti, on: true, output: all }
├─LogicalScan { table: t1, output_columns: [t1.v1, t1.v2], required_columns: [v1, v2], predicate: IsNull(t1.v1) AND IsNull(t1.v2) }
├─LogicalScan { table: t1, columns: [t1.v1, t1.v2], predicate: IsNull(t1.v1) AND IsNull(t1.v2) }
└─LogicalScan { table: t2, columns: [] }
6 changes: 3 additions & 3 deletions src/frontend/planner_test/tests/testdata/subquery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
├─LogicalScan { table: ab, columns: [ab.a, ab.b] }
└─LogicalJoin { type: Inner, on: true, output: all }
├─LogicalScan { table: bc, columns: [bc.b] }
└─LogicalScan { table: t, output_columns: [], required_columns: [v1], predicate: IsNotNull(t.v1) }
└─LogicalScan { table: t, output_columns: [], required_columns: [t.v1], predicate: IsNotNull(t.v1) }
- name: We cannot reference columns in left table if not lateral
sql: |
create table ab (a int, b int);
Expand Down Expand Up @@ -259,7 +259,7 @@
optimized_logical_plan: |
LogicalProject { exprs: [1:Int32] }
└─LogicalJoin { type: LeftSemi, on: true, output: all }
├─LogicalScan { table: t, output_columns: [], required_columns: [v], predicate: (t.v > 1:Int32) }
├─LogicalScan { table: t, output_columns: [], required_columns: [t.v], predicate: (t.v > 1:Int32) }
└─LogicalAgg { aggs: [] }
└─LogicalValues { rows: [[]], schema: Schema { fields: [] } }
- sql: |
Expand Down Expand Up @@ -331,7 +331,7 @@
├─LogicalAgg { group_key: [a.a1], aggs: [] }
| └─LogicalScan { table: a, columns: [a.a1] }
└─LogicalProject { exprs: [b.b1, b.b1] }
└─LogicalScan { table: b, output_columns: [b.b1], required_columns: [b1], predicate: IsNotNull(b.b1) }
└─LogicalScan { table: b, columns: [b.b1], predicate: IsNotNull(b.b1) }
- name: test subquery in join on condition
sql: |
create table a (v1 int, v2 int);
Expand Down
Loading

0 comments on commit 87279ad

Please sign in to comment.