haohuaijin commented on code in PR #25568:
URL: https://github.com/apache/datafusion/pull/25568#discussion_r4063387256
##########
datafusion/sqllogictest/test_files/order.slt:
##########
@@ -1966,11 +1966,13 @@ EXPLAIN SELECT * from ordered ORDER BY (a + b);
----
physical_plan DataSourceExec: file_groups={1 group:
[[WORKSPACE_ROOT/datafusion/sqllogictest/data/composite_order.csv]]},
projection=[a, b], output_ordering=[a@0 + b@1 ASC NULLS LAST], file_type=csv,
has_header=true
-# Order equivalence handling should make this query a simple table scan
+# Negation may wrap at BIGINT's minimum, so the declared ordering is
insufficient.
query TT
EXPLAIN SELECT * from ordered ORDER BY -(a + b) desc nulls last;
----
-physical_plan DataSourceExec: file_groups={1 group:
[[WORKSPACE_ROOT/datafusion/sqllogictest/data/composite_order.csv]]},
projection=[a, b], output_ordering=[a@0 + b@1 ASC NULLS LAST], file_type=csv,
has_header=true
+physical_plan
+01)SortExec: expr=[(- a@0 + b@1) DESC NULLS LAST],
preserve_partitioning=[false]
+02)--DataSourceExec: file_groups={1 group:
[[WORKSPACE_ROOT/datafusion/sqllogictest/data/composite_order.csv]]},
projection=[a, b], output_ordering=[a@0 + b@1 ASC NULLS LAST], file_type=csv,
has_header=true
Review Comment:
As a follow-up to #25220, exact column statistics could prove that `a + b`
cannot reach `INT_MIN`, allowing us to safely reverse the declared ordering and
eliminate this SortExec.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]