neilconway commented on code in PR #21362:
URL: https://github.com/apache/datafusion/pull/21362#discussion_r3066706657


##########
datafusion/sqllogictest/test_files/order.slt:
##########
@@ -1521,7 +1579,7 @@ query TT
 EXPLAIN SELECT c1, c2 FROM table_with_ordered_pk ORDER BY c1, c2;
 ----
 logical_plan
-01)Sort: table_with_ordered_pk.c1 ASC NULLS LAST, table_with_ordered_pk.c2 ASC 
NULLS LAST
+01)Sort: table_with_ordered_pk.c1 ASC NULLS LAST

Review Comment:
   Hmm, the optimization seems sound to me. If c1 functionally determines c2, 
we know that each distinct c1 value is associated with exactly one c2 value. So 
sorting by c1 is sufficient; adding in c2 as a tiebreaker / secondary sort key 
is never useful.
   
   In the example, if `c1` is a PK of `table`, sorting by c1 is sufficient to 
get the right sort order -- there will never be two rows with the same `c1` 
value.



-- 
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]

Reply via email to