Skip to content

Apache DataFusion SQL Query Engine

Fix intermittent SQL logic test failure in limit.slt by adding ORDER BY clause (#16257)

kosiew4cf1148b3679
diff --git a/datafusion/sqllogictest/test_files/limit.slt b/datafusion/sqllogictest/test_files/limit.slt
index 2f8944f462..9d5106bf2c 100644
--- a/datafusion/sqllogictest/test_files/limit.slt
+++ b/datafusion/sqllogictest/test_files/limit.slt
@@ -835,6 +835,7 @@ explain
with selection as (
select *
from test_limit_with_partitions
+ order by part_key
limit 1
)
select 1 as foo
@@ -847,19 +848,19 @@ logical_plan
02)--Sort: selection.part_key ASC NULLS LAST, fetch=1000
03)----Projection: Int64(1) AS foo, selection.part_key
04)------SubqueryAlias: selection
-05)--------Limit: skip=0, fetch=1
-06)----------TableScan: test_limit_with_partitions projection=[part_key], fetch=1
+05)--------Sort: test_limit_with_partitions.part_key ASC NULLS LAST, fetch=1
+06)----------TableScan: test_limit_with_partitions projection=[part_key]
physical_plan
-01)ProjectionExec: expr=[foo@0 as foo]
-02)--SortExec: TopK(fetch=1000), expr=[part_key@1 ASC NULLS LAST], preserve_partitioning=[false]
-03)----ProjectionExec: expr=[1 as foo, part_key@0 as part_key]
-04)------CoalescePartitionsExec: fetch=1
-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
+01)ProjectionExec: expr=[1 as foo]
+02)--SortPreservingMergeExec: [part_key@0 ASC NULLS LAST], fetch=1
+03)----SortExec: TopK(fetch=1), expr=[part_key@0 ASC NULLS LAST], preserve_partitioning=[true]
+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
query I
with selection as (
select *
from test_limit_with_partitions
+ order by part_key
limit 1
)
select 1 as foo