alamb commented on code in PR #15260:
URL: https://github.com/apache/datafusion/pull/15260#discussion_r1999228102


##########
datafusion/catalog/Cargo.toml:
##########
@@ -35,17 +35,18 @@ arrow = { workspace = true }
 async-trait = { workspace = true }
 dashmap = { workspace = true }
 datafusion-common = { workspace = true }
+datafusion-common-runtime = { workspace = true }
 datafusion-execution = { workspace = true }
 datafusion-expr = { workspace = true }
+datafusion-optimizer = { workspace = true }

Review Comment:
   I think it would be really nice to avoid  the new dependency on the 
datafusion-optimizer crate here -- 
   
   However, it seems like it is related to the fact that coercion is part of 
the optimizer crate 🤔
   
   I can think of two ways to avoid this:
   1. Make the caller of `ViewTable::try_new`  call `coerce_types` directly
   2. Move the coercion into a new crate (seems overkill)
   
   But the more I think about this the less of a problem I think it is
   



##########
datafusion/catalog/src/lib.rs:
##########
@@ -46,4 +46,94 @@ pub use r#async::*;
 pub use schema::*;
 pub use session::*;
 pub use table::*;
+pub mod stream;
 pub mod streaming;
+pub mod view;
+
+use arrow::compute::SortOptions;
+use arrow::datatypes::Schema;
+use datafusion_common::plan_err;
+use datafusion_common::Result;
+use datafusion_expr::{Expr, SortExpr};
+use datafusion_physical_expr::{expressions, LexOrdering, PhysicalSortExpr};
+
+/// Converts logical sort expressions to physical sort expressions
+///
+/// This function transforms a collection of logical sort expressions into 
their physical
+/// representation that can be used during query execution.
+///
+/// # Arguments
+///
+/// * `schema` - The schema containing column definitions
+/// * `sort_order` - A collection of logical sort expressions grouped into 
lexicographic orderings
+///
+/// # Returns
+///
+/// A vector of lexicographic orderings for physical execution, or an error if 
the transformation fails
+///
+/// # Examples
+///
+/// ```
+/// // Create orderings from columns "id" and "name"
+/// # use arrow::datatypes::{Schema, Field, DataType};
+/// # use datafusion_catalog::create_ordering;
+/// # use datafusion_common::Column;
+/// # use datafusion_expr::{Expr, SortExpr};
+/// #
+/// // Create a schema with two fields
+/// let schema = Schema::new(vec![
+///     Field::new("id", DataType::Int32, false),
+///     Field::new("name", DataType::Utf8, false),
+/// ]);
+///
+/// let sort_exprs = vec![
+///     vec![
+///         SortExpr { expr: Expr::Column(Column::new(Some("t"), "id")), asc: 
true, nulls_first: false }
+///     ],
+///     vec![
+///         SortExpr { expr: Expr::Column(Column::new(Some("t"), "name")), 
asc: false, nulls_first: true }
+///     ]
+/// ];
+/// let result = create_ordering(&schema, &sort_exprs).unwrap();
+/// ```
+pub fn create_ordering(

Review Comment:
   I think this function would make more sense in `physical-expr` directly. It 
seems like physical-expr already depends on `Expr` 
   
   
https://github.com/apache/datafusion/blob/00331cf2a2248048a05cd74ebd930e1bbbeea48d/datafusion/physical-expr/Cargo.toml#L44
   
   



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to