Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
create_ordering in datafusion::physical_expr - Rust
[go: Go Back, main page]

Function create_ordering

Source
pub fn create_ordering(
    schema: &Schema,
    sort_order: &[Vec<Sort>],
) -> Result<Vec<LexOrdering>, DataFusionError>
Expand description

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"
// 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();