marvelefe commented on code in PR #27470:
URL: https://github.com/apache/datafusion/pull/27470#discussion_r4607118964


##########
datafusion/physical-expr/src/equivalence/ordering.rs:
##########
@@ -282,15 +282,42 @@ impl IntoIterator for OrderingEquivalenceClass {
     }
 }
 
+/// Renders an ordering with `NULLS FIRST`/`NULLS LAST` spelled out. The
+/// `PhysicalSortExpr` display leaves `NULLS FIRST` implicit for `ASC`, which 
is
+/// ambiguous when reading equivalence properties.
+pub(crate) struct ExplicitNullsOrdering<'a>(pub(crate) &'a LexOrdering);
+
+impl Display for ExplicitNullsOrdering<'_> {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        for (idx, sort_expr) in self.0.iter().enumerate() {
+            if idx > 0 {
+                write!(f, ", ")?;
+            }
+            let direction = if sort_expr.options.descending {
+                "DESC"
+            } else {
+                "ASC"
+            };
+            let nulls = if sort_expr.options.nulls_first {
+                "FIRST"
+            } else {
+                "LAST"
+            };
+            write!(f, "{} {direction} NULLS {nulls}", sort_expr.expr)?;

Review Comment:
   @jayzhan211 Updated. It now reuses arrow's `SortOptions` `Display`



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