Skip to content

Commit 4b81013

Browse files
committed
Fix intermittent SQL logic test failure in limit.slt by adding ORDER BY clause (apache#16257)
* Add order by clause to limit query for consistent results * test: update explain plan
1 parent b874291 commit 4b81013

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

datafusion/sqllogictest/test_files/limit.slt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ explain
835835
with selection as (
836836
select *
837837
from test_limit_with_partitions
838+
order by part_key
838839
limit 1
839840
)
840841
select 1 as foo
@@ -847,19 +848,19 @@ logical_plan
847848
02)--Sort: selection.part_key ASC NULLS LAST, fetch=1000
848849
03)----Projection: Int64(1) AS foo, selection.part_key
849850
04)------SubqueryAlias: selection
850-
05)--------Limit: skip=0, fetch=1
851-
06)----------TableScan: test_limit_with_partitions projection=[part_key], fetch=1
851+
05)--------Sort: test_limit_with_partitions.part_key ASC NULLS LAST, fetch=1
852+
06)----------TableScan: test_limit_with_partitions projection=[part_key]
852853
physical_plan
853-
01)ProjectionExec: expr=[foo@0 as foo]
854-
02)--SortExec: TopK(fetch=1000), expr=[part_key@1 ASC NULLS LAST], preserve_partitioning=[false]
855-
03)----ProjectionExec: expr=[1 as foo, part_key@0 as part_key]
856-
04)------CoalescePartitionsExec: fetch=1
857-
05)--------DataSourceExec: file_groups={3 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet/test_limit_with_partitions/part-0.parquet:0..794], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet/test_limit_with_partitions/part-1.parquet:0..794], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet/test_limit_with_partitions/part-2.parquet:0..794]]}, projection=[part_key], limit=1, file_type=parquet
854+
01)ProjectionExec: expr=[1 as foo]
855+
02)--SortPreservingMergeExec: [part_key@0 ASC NULLS LAST], fetch=1
856+
03)----SortExec: TopK(fetch=1), expr=[part_key@0 ASC NULLS LAST], preserve_partitioning=[true]
857+
04)------DataSourceExec: file_groups={3 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet/test_limit_with_partitions/part-0.parquet:0..794], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet/test_limit_with_partitions/part-1.parquet:0..794], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet/test_limit_with_partitions/part-2.parquet:0..794]]}, projection=[part_key], file_type=parquet
858858

859859
query I
860860
with selection as (
861861
select *
862862
from test_limit_with_partitions
863+
order by part_key
863864
limit 1
864865
)
865866
select 1 as foo

0 commit comments

Comments
 (0)