Skip to content

Commit 2099882

Browse files
kosiewxudong963
authored andcommitted
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 d8c3e03 commit 2099882

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

datafusion/sqllogictest/test_files/limit.slt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -830,14 +830,12 @@ CREATE EXTERNAL TABLE test_limit_with_partitions
830830
STORED AS PARQUET
831831
LOCATION 'test_files/scratch/parquet/test_limit_with_partitions/';
832832

833-
statement ok
834-
set datafusion.explain.logical_plan_only = true;
835-
836833
query TT
837834
explain
838835
with selection as (
839836
select *
840837
from test_limit_with_partitions
838+
order by part_key
841839
limit 1
842840
)
843841
select 1 as foo
@@ -850,16 +848,19 @@ logical_plan
850848
02)--Sort: selection.part_key ASC NULLS LAST, fetch=1000
851849
03)----Projection: Int64(1) AS foo, selection.part_key
852850
04)------SubqueryAlias: selection
853-
05)--------Limit: skip=0, fetch=1
854-
06)----------TableScan: test_limit_with_partitions projection=[part_key], fetch=1
855-
856-
statement ok
857-
set datafusion.explain.logical_plan_only = false;
851+
05)--------Sort: test_limit_with_partitions.part_key ASC NULLS LAST, fetch=1
852+
06)----------TableScan: test_limit_with_partitions projection=[part_key]
853+
physical_plan
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)