Skip to content

Commit

Permalink
test: add planner test case for distinct on (#19048)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyufjh authored Oct 22, 2024
1 parent 9b42fb0 commit 4745119
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
12 changes: 9 additions & 3 deletions src/frontend/planner_test/tests/testdata/input/agg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,20 +296,26 @@
expected_outputs:
- logical_plan
- batch_plan
- name: distinct on
- name: distinct on order by distinct columns
sql: |
create table t (v1 int, v2 int, v3 int);
select distinct on (v1, v3) v1, v2 from t order by v1, v3;
expected_outputs:
- logical_plan
- batch_plan
- name: distinct on
- name: distinct on order by part of the distinct columns
sql: |
create table t (v1 int, v2 int);
select distinct on (v1) v1, v2 from t order by v1;
expected_outputs:
- logical_plan
- name: distinct on
- name: distinct on order by distinct columns and additional sorting columns
sql: |
create table t (id int, ts timestamp, foo int, bar varchar);
select distinct on (id) * from t order by id, ts desc;
expected_outputs:
- logical_plan
- name: distinct on with expression
sql: |
create table t (v1 int, v2 int, v3 int);
select distinct on(v1) v2 + v3 from t order by v1;
Expand Down
14 changes: 11 additions & 3 deletions src/frontend/planner_test/tests/testdata/output/agg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@
└─BatchGroupTopN { order: [t.v3 ASC, t.v1 ASC], limit: 1, offset: 0, group_key: [t.v1, t.v3] }
└─BatchExchange { order: [], dist: HashShard(t.v1, t.v3) }
└─BatchScan { table: t, columns: [t.v1, t.v2, t.v3], distribution: SomeShard }
- name: distinct on
- name: distinct on order by distinct columns
sql: |
create table t (v1 int, v2 int, v3 int);
select distinct on (v1, v3) v1, v2 from t order by v1, v3;
Expand All @@ -508,15 +508,23 @@
└─BatchGroupTopN { order: [t.v1 ASC, t.v3 ASC], limit: 1, offset: 0, group_key: [t.v1, t.v3] }
└─BatchExchange { order: [], dist: HashShard(t.v1, t.v3) }
└─BatchScan { table: t, columns: [t.v1, t.v2, t.v3], distribution: SomeShard }
- name: distinct on
- name: distinct on order by part of the distinct columns
sql: |
create table t (v1 int, v2 int);
select distinct on (v1) v1, v2 from t order by v1;
logical_plan: |-
LogicalTopN { order: [t.v1 ASC], limit: 1, offset: 0, group_key: [t.v1] }
└─LogicalProject { exprs: [t.v1, t.v2] }
└─LogicalScan { table: t, columns: [t.v1, t.v2, t._row_id] }
- name: distinct on
- name: distinct on order by distinct columns and additional sorting columns
sql: |
create table t (id int, ts timestamp, foo int, bar varchar);
select distinct on (id) * from t order by id, ts desc;
logical_plan: |-
LogicalTopN { order: [t.id ASC, t.ts DESC], limit: 1, offset: 0, group_key: [t.id] }
└─LogicalProject { exprs: [t.id, t.ts, t.foo, t.bar] }
└─LogicalScan { table: t, columns: [t.id, t.ts, t.foo, t.bar, t._row_id] }
- name: distinct on with expression
sql: |
create table t (v1 int, v2 int, v3 int);
select distinct on(v1) v2 + v3 from t order by v1;
Expand Down

0 comments on commit 4745119

Please sign in to comment.