MCPcopy Create free account
hub / github.com/apache/datafusion / to_order_by_exprs_with_select

Function to_order_by_exprs_with_select

datafusion/sql/src/query.rs:390–428  ·  view source on GitHub ↗

Returns the order by expressions from the query with the select expressions.

(
    order_by: Option<OrderBy>,
    select_exprs: Option<&Vec<Expr>>,
)

Source from the content-addressed store, hash-verified

388
389/// Returns the order by expressions from the query with the select expressions.
390pub(crate) fn to_order_by_exprs_with_select(
391 order_by: Option<OrderBy>,
392 select_exprs: Option<&Vec<Expr>>,
393) -> Result<Vec<OrderByExpr>> {
394 let Some(OrderBy { kind, interpolate }) = order_by else {
395 // If no order by, return an empty array.
396 return Ok(vec![]);
397 };
398 if let Some(_interpolate) = interpolate {
399 return not_impl_err!("ORDER BY INTERPOLATE is not supported");
400 }
401 match kind {
402 OrderByKind::All(order_by_options) => {
403 let Some(exprs) = select_exprs else {
404 return Ok(vec![]);
405 };
406 let order_by_exprs = exprs
407 .iter()
408 .map(|select_expr| match select_expr {
409 Expr::Column(column) => Ok(OrderByExpr {
410 expr: SQLExpr::Identifier(Ident {
411 value: column.name.clone(),
412 quote_style: None,
413 span: Span::empty(),
414 }),
415 options: order_by_options,
416 with_fill: None,
417 }),
418 // TODO: Support other types of expressions
419 _ => not_impl_err!(
420 "ORDER BY ALL is not supported for non-column expressions"
421 ),
422 })
423 .collect::<Result<Vec<_>>>()?;
424 Ok(order_by_exprs)
425 }
426 OrderByKind::Expressions(order_by_exprs) => Ok(order_by_exprs),
427 }
428}

Callers 2

select_to_planMethod · 0.85
to_order_by_exprsFunction · 0.85

Calls 5

IdentifierClass · 0.85
emptyFunction · 0.50
mapMethod · 0.45
iterMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…