Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProjectSet has wrong sort order caused by projected_row_id #17448

Open
xxchan opened this issue Jun 25, 2024 · 4 comments
Open

ProjectSet has wrong sort order caused by projected_row_id #17448

xxchan opened this issue Jun 25, 2024 · 4 comments
Assignees
Labels
component/optimizer Query optimization. type/bug Something isn't working
Milestone

Comments

@xxchan
Copy link
Member

xxchan commented Jun 25, 2024

          ![image](https://github.com/risingwavelabs/risingwave/assets/14160025/277f09d6-078e-4791-906b-d337fcba3e9f)

Still flaky? 👀

https://buildkite.com/risingwavelabs/pull-request/builds/52699#01904eb3-fde8-4565-8072-b1452cac7162

Originally posted by @yezizp2012 in #17441 (comment)

@github-actions github-actions bot added this to the release-1.10 milestone Jun 25, 2024
@yuhao-su
Copy link
Contributor

@xxchan
Copy link
Member Author

xxchan commented Jun 26, 2024

dev=> explain WITH arr AS (SELECT header_col_combined FROM additional_columns limit 1)
SELECT unnest(header_col_combined) FROM arr ORDER BY 1;
┌───────────────────────────────────────────────────────────────────────────────────────────────┐
│                                          QUERY PLAN                                           │
├───────────────────────────────────────────────────────────────────────────────────────────────┤
│ BatchProject { exprs: [Unnest($0)] }                                                          │
│ └─BatchSort { order: [projected_row_id ASC] }      <--------                                            │
│   └─BatchProjectSet { select_list: [Unnest($0)] }                                             │
│     └─BatchLimit { limit: 1, offset: 0 }                                                      │
│       └─BatchExchange { order: [], dist: Single, sequential: true }                           │
│         └─BatchLimit { limit: 1, offset: 0 }                                                  │
│           └─BatchScan { table: additional_columns, columns: [header_col_combined], limit: 1 } │
└───────────────────────────────────────────────────────────────────────────────────────────────┘
(7 rows)

@xxchan
Copy link
Member Author

xxchan commented Jun 26, 2024


dev=> select unnest(array[1,2,1]) order by 1;
┌────────┐
│ unnest │
├────────┤
│      1 │
│      2 │
│      1 │
└────────┘
(3 rows)

dev=> explain select unnest(array[1,2,1]) order by 1;
┌───────────────────────────────────────────────────────────────────────────┐
│                                QUERY PLAN                                 │
├───────────────────────────────────────────────────────────────────────────┤
│ BatchProject { exprs: [Unnest(ARRAY[1, 2, 1]:List(Int32))] }              │
│ └─BatchSort { order: [projected_row_id ASC] }                             │
│   └─BatchProjectSet { select_list: [Unnest(ARRAY[1, 2, 1]:List(Int32))] } │
│     └─BatchValues { rows: [[]] }                                          │
└───────────────────────────────────────────────────────────────────────────┘
dev=> explain select 6 as x, unnest(array[1,2,1]) order by x;
┌────────────────────────────────────────────────────────────────────────────────────┐
│                                     QUERY PLAN                                     │
├────────────────────────────────────────────────────────────────────────────────────┤
│ BatchProject { exprs: [6:Int32, Unnest(ARRAY[1, 2, 1]:List(Int32))] }              │
│ └─BatchSort { order: [projected_row_id ASC] }                                      │
│   └─BatchProjectSet { select_list: [6:Int32, Unnest(ARRAY[1, 2, 1]:List(Int32))] } │
│     └─BatchValues { rows: [[]] }                                                   │
└────────────────────────────────────────────────────────────────────────────────────┘
(4 rows)

dev=> explain select 6 as x, unnest(array[1,2,1]) order by unnest;
┌────────────────────────────────────────────────────────────────────────────────────┐
│                                     QUERY PLAN                                     │
├────────────────────────────────────────────────────────────────────────────────────┤
│ BatchProject { exprs: [6:Int32, Unnest(ARRAY[1, 2, 1]:List(Int32))] }              │
│ └─BatchSort { order: [6:Int32 ASC] }                                               │
│   └─BatchProjectSet { select_list: [6:Int32, Unnest(ARRAY[1, 2, 1]:List(Int32))] } │
│     └─BatchValues { rows: [[]] }                                                   │
└────────────────────────────────────────────────────────────────────────────────────┘

@xxchan xxchan changed the title flaky test flaky test: caused by ProjectSet sorted by projected_row_id Jun 26, 2024
@xxchan
Copy link
Member Author

xxchan commented Jun 26, 2024

Also for streaming

explain create materialized view mv as select unnest(array[1,2,1]) order by 1 limit 1;

┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│                                                                        QUERY PLAN                                                                        │
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ StreamMaterialize { columns: [projected_row_id(hidden), unnest, _row_id(hidden)], stream_key: [], pk_columns: [projected_row_id], pk_conflict: NoCheck } │
│ └─StreamTopN [append_only] { order: [projected_row_id ASC], limit: 1, offset: 0 }                                                                        │
│   └─StreamProjectSet { select_list: [Unnest(ARRAY[1, 2, 1]:List(Int32)), $0] }                                                                           │
│     └─StreamValues { rows: [[0:Int64]] }                                                                                                                 │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

@xxchan xxchan changed the title flaky test: caused by ProjectSet sorted by projected_row_id ProjectSet has wrong sort order caused by projected_row_id Jun 26, 2024
@BugenZhao BugenZhao added type/bug Something isn't working component/optimizer Query optimization. labels Jun 26, 2024
@xxchan xxchan self-assigned this Jul 10, 2024
@xxchan xxchan modified the milestones: release-2.0, release-2.1 Aug 19, 2024
@xxchan xxchan modified the milestones: release-2.1, release-2.2 Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/optimizer Query optimization. type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants