Skip to content

fix: parquet files record the right sort column after a struct column - #27721

Open
TechWizard9999 wants to merge 2 commits into
apache:mainfrom
TechWizard9999:fix/parquet-sort-leaf-index
Open

TechWizard9999 wants to merge 2 commits into
apache:mainfrom
TechWizard9999:fix/parquet-sort-leaf-index

Conversation

@TechWizard9999

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

Order by could return unsorted rows when a struct column comes before the sort key in a parquet file.

What changes are included in this PR?

Write the parquet leaf column index for the sort order. a struct sort key now writes no sort order.

What is the testing strategy for this PR?

Added slt tests and a unit test.

Are there any user-facing changes?

Yes, these files now record the right sort order, so order by returns sorted rows.

@TechWizard9999

Copy link
Copy Markdown
Contributor Author

@kosiew Please review. Thanks!

@github-actions github-actions Bot added sqllogictest SQL Logic Tests (.slt) datasource Changes to the datasource crate labels Nov 24, 2026

@alamb alamb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR @TechWizard9999

2
2

# The file is sorted by b, so ORDER BY b needs no sort

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the plan shows a sort so I don't understand this comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified the comment, thanks!

2

query I
SELECT b FROM struct_sort_key ORDER BY b;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please show these plans too via EXPLAIN so we cn verify if there is a sort or not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the plans, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

datasource Changes to the datasource crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong ORDER BY results on Parquet files with a struct column before the sort key

2 participants