logan-keede commented on code in PR #15260: URL: https://github.com/apache/datafusion/pull/15260#discussion_r1999958674
########## 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: seems reasonable, moved. -- 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