berkaysynnada commented on code in PR #6441:
URL: https://github.com/apache/arrow-rs/pull/6441#discussion_r1772771257


##########
arrow-schema/src/lib.rs:
##########
@@ -42,6 +73,56 @@ pub struct SortOptions {
     pub nulls_first: bool,
 }
 
+impl Display for SortOptions {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        if self.descending {
+            write!(f, "DESC")?;
+        } else {
+            write!(f, "ASC")?;
+        }
+        if self.nulls_first {
+            write!(f, " NULLS FIRST")?;
+        } else {
+            write!(f, " NULLS LAST")?;
+        }
+        Ok(())
+    }
+}
+
+impl SortOptions {
+    /// Create a new `SortOptions` struct
+    pub fn new(descending: bool, nulls_first: bool) -> Self {
+        Self {
+            descending,
+            nulls_first,
+        }
+    }
+
+    /// Set this sort options to sort in descending order
+    pub fn desc(mut self) -> Self {
+        self.descending = true;
+        self
+    }
+
+    /// Set this sort options to sort in ascending order
+    pub fn asc(mut self) -> Self {
+        self.descending = false;
+        self
+    }
+
+    /// Set this sort options to sort descending if argument is true
+    pub fn with_descending(mut self, descending: bool) -> Self {
+        self.descending = descending;
+        self
+    }
+
+    /// Set this sort options to sort nulls first if argument is true
+    pub fn with_nulls_first(mut self, nulls_first: bool) -> Self {

Review Comment:
   We can keep this API for sure, but to be consistent with what you propose at 
https://github.com/apache/datafusion/pull/12595 (`nulls_first()` / 
`nulls_last()` API for `PhysicalSortExpr`), should we add `nulls_first()` and 
`nulls_last()` here, too?



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

Reply via email to