Fix intermittent SQL logic test failure in limit.slt by adding ORDER BY clause#16257
Merged
andygrove merged 4 commits intoapache:mainfrom Jun 6, 2025
Merged
Fix intermittent SQL logic test failure in limit.slt by adding ORDER BY clause#16257andygrove merged 4 commits intoapache:mainfrom
andygrove merged 4 commits intoapache:mainfrom
Conversation
alamb
reviewed
Jun 5, 2025
| with selection as ( | ||
| select * | ||
| from test_limit_with_partitions | ||
| order by part_key |
jonathanc-n
approved these changes
Jun 6, 2025
Contributor
Author
|
Thanks @jonathanc-n for the review. |
alamb
approved these changes
Jun 6, 2025
Contributor
alamb
left a comment
There was a problem hiding this comment.
Thanks @kosiew and @jonathanc-n
andygrove
approved these changes
Jun 6, 2025
kosiew
added a commit
to kosiew/datafusion
that referenced
this pull request
Jun 9, 2025
…BY clause (apache#16257) * Add order by clause to limit query for consistent results * test: update explain plan
crepererum
pushed a commit
to influxdata/arrow-datafusion
that referenced
this pull request
Jul 17, 2025
…BY clause (apache#16257) * Add order by clause to limit query for consistent results * test: update explain plan
findepi
pushed a commit
to sdf-labs/datafusion
that referenced
this pull request
Aug 13, 2025
…ing ORDER BY clause (apache#16257) * Add order by clause to limit query for consistent results * test: update explain plan (cherry picked from commit 4cf1148)
xudong963
pushed a commit
to massive-com/arrow-datafusion
that referenced
this pull request
Aug 25, 2025
…BY clause (apache#16257) * Add order by clause to limit query for consistent results * test: update explain plan
findepi
pushed a commit
to sdf-labs/datafusion
that referenced
this pull request
Sep 5, 2025
…ing ORDER BY clause (apache#16257) * Add order by clause to limit query for consistent results * test: update explain plan (cherry picked from commit 4cf1148)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
test_files/limit.slt#16180.Rationale for this change
Intermittent test failures were observed in the
limit.sltSQL logic test file on themainbranch, specifically related to a query that uses aLIMITclause without anORDER BY. Since SQLLIMITbehavior is non-deterministic without a defined order, this led to flaky test results.This change explicitly adds an
ORDER BY part_keyto theLIMITsubquery to ensure deterministic results and resolve test flakiness.What changes are included in this PR?
ORDER BY part_keybefore theLIMITclause.Sortoperator before the limit.SortPreservingMergeExecto maintain global ordering across partitions.DataSourceExecwith a combination ofSortExecandTopKon each partition to correctly apply the limit post-sort.Are these changes tested?
Yes. The change modifies an existing SQL logic test to enforce a deterministic result, which now consistently passes in CI runs.
Tested with:
Are there any user-facing changes?
No. This change only affects internal test stability and does not impact the user-facing API or behavior.