alamb commented on code in PR #16900:
URL: https://github.com/apache/datafusion/pull/16900#discussion_r2230908262


##########
datafusion/sqllogictest/test_files/partial_sorts.slt:
##########
@@ -0,0 +1,132 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+
+#   http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+query I
+COPY (values
+(1, 'a'),
+(2, 'b'),
+(3, 'd'),
+(4, 'e'),
+(5, 'a')
+) TO 'test_files/scratch/partial_sorts/data.csv' STORED AS CSV;
+----
+5
+
+statement ok
+CREATE EXTERNAL TABLE data (
+    a int,
+    b string
+)
+STORED AS CSV
+LOCATION 'test_files/scratch/partial_sorts/data.csv'
+WITH ORDER (a);
+
+# Expect no sort is necessary when the data is already sorted
+query TT
+EXPLAIN SELECT * FROM data ORDER BY a;
+----
+logical_plan
+01)Sort: data.a ASC NULLS LAST
+02)--TableScan: data projection=[a, b]
+physical_plan DataSourceExec: file_groups={1 group: 
[[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/partial_sorts/data.csv]]},
 projection=[a, b], output_ordering=[a@0 ASC NULLS LAST], file_type=csv, 
has_header=true
+
+query IT
+SELECT * FROM data ORDER BY a;
+----
+1 a
+2 b
+3 d
+4 e
+5 a
+
+# Expect we only need a PartialSort since 'a' is already sorted
+# Note it uses a Full SortExec due to 
https://github.com/apache/datafusion/issues/16899
+query TT
+EXPLAIN SELECT * FROM data ORDER BY a, b;
+----
+logical_plan
+01)Sort: data.a ASC NULLS LAST, data.b ASC NULLS LAST
+02)--TableScan: data projection=[a, b]
+physical_plan
+01)SortExec: expr=[a@0 ASC NULLS LAST, b@1 ASC NULLS LAST], 
preserve_partitioning=[false]

Review Comment:
   > Do you want to see some PartialSortExec in these new tests?
   
   @berkaysynnada  Yes, I expect to see PartialSortExec here specifically
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to