Apache DataFusion SQL Query Engine
minor: Add `PhysicalSortExpr::new` (#11310)
Andy Grove229c1398d6bc
diff --git a/datafusion/physical-expr-common/src/sort_expr.rs b/datafusion/physical-expr-common/src/sort_expr.rsindex f637355519..8fb1356a80 100644--- a/datafusion/physical-expr-common/src/sort_expr.rs+++ b/datafusion/physical-expr-common/src/sort_expr.rs@@ -39,6 +39,13 @@ pub struct PhysicalSortExpr {pub options: SortOptions,}+impl PhysicalSortExpr {+ /// Create a new PhysicalSortExpr+ pub fn new(expr: Arc<dyn PhysicalExpr>, options: SortOptions) -> Self {+ Self { expr, options }+ }+}+impl PartialEq for PhysicalSortExpr {fn eq(&self, other: &PhysicalSortExpr) -> bool {self.options == other.options && self.expr.eq(&other.expr)@@ -155,10 +162,7 @@ impl From<PhysicalSortRequirement> for PhysicalSortExpr {descending: false,nulls_first: false,});- PhysicalSortExpr {- expr: value.expr,- options,- }+ PhysicalSortExpr::new(value.expr, options)}}@@ -281,16 +285,13 @@ pub fn limited_convert_logical_sort_exprs_to_physical(let Expr::Sort(sort) = expr else {return exec_err!("Expects to receive sort expression");};- sort_exprs.push(PhysicalSortExpr {- expr: limited_convert_logical_expr_to_physical_expr(- sort.expr.as_ref(),- schema,- )?,- options: SortOptions {+ sort_exprs.push(PhysicalSortExpr::new(+ limited_convert_logical_expr_to_physical_expr(sort.expr.as_ref(), schema)?,+ SortOptions {descending: !sort.asc,nulls_first: sort.nulls_first,},- });+ ))}Ok(sort_exprs)}diff --git a/datafusion/physical-expr-common/src/utils.rs b/datafusion/physical-expr-common/src/utils.rsindex d5cd3c6f4a..44622bd309 100644--- a/datafusion/physical-expr-common/src/utils.rs+++ b/datafusion/physical-expr-common/src/utils.rs@@ -104,10 +104,7 @@ pub fn scatter(mask: &BooleanArray, truthy: &dyn Array) -> Result<ArrayRef> {pub fn reverse_order_bys(order_bys: &[PhysicalSortExpr]) -> Vec<PhysicalSortExpr> {order_bys.iter()- .map(|e| PhysicalSortExpr {- expr: e.expr.clone(),- options: !e.options,- })+ .map(|e| PhysicalSortExpr::new(e.expr.clone(), !e.options)).collect()}