alamb commented on code in PR #5863:
URL: https://github.com/apache/arrow-datafusion/pull/5863#discussion_r1158486095


##########
datafusion/physical-expr/src/sort_expr.rs:
##########
@@ -107,19 +147,94 @@ impl std::fmt::Display for PhysicalSortRequirement {
 }
 
 impl PhysicalSortRequirement {
+    /// Creates a new `exact` requirement, which must match the
+    /// required options and expression. See
+    /// [`PhysicalSortRequirement`] for examples.
+    pub fn new_exact(expr: Arc<dyn PhysicalExpr>, options: SortOptions) -> 
Self {
+        Self {
+            expr,
+            options: Some(options),
+        }
+    }
+
+    /// Creates a new `expr_only` requirement, which must match the
+    /// required expression. See [`PhysicalSortRequirement`] for
+    /// examples.
+    pub fn new_expr_only(expr: Arc<dyn PhysicalExpr>) -> Self {
+        Self {
+            expr,
+            options: None,
+        }
+    }

Review Comment:
   Yes - that is precisely the reason.
   
   For example, I thought it was clearer that the goal was to add a relaxed 
sort requirement in `datafusion/core/src/physical_plan/windows/mod.rs`  with:
   
   ```rust
    for partition_by in partition_by_exprs {
           
sort_reqs.push(PhysicalSortRequirement::new_expr_only(partition_by.clone()))
       }
   ```
   
   Rather than 
   ```rust
    for partition_by in partition_by_exprs {
          sort_reqs.push(PhysicalSortRequirement {
               expr: partition_by.clone(),
               options: None,
           });
       }
   ```
   
   Of course they both do the same thing eventually and I agree it is a 
preference thing about what makes for more readable code



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