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

Function rebase_expr

datafusion/sql/src/utils.rs:79–93  ·  view source on GitHub ↗

Rebuilds an `Expr` as a projection on top of a collection of `Expr`'s. For example, the expression `a + b < 1` would require, as input, the 2 individual columns, `a` and `b`. But, if the base expressions already contain the `a + b` result, then that may be used in lieu of the `a` and `b` columns. This is useful in the context of a query like: SELECT a + b < 1 ... GROUP BY a + b where post-aggr

(
    expr: &Expr,
    base_exprs: &[Expr],
    plan: &LogicalPlan,
)

Source from the content-addressed store, hash-verified

77/// individual columns `a` and `b`, but rather it is a projection against the
78/// `a + b` found in the GROUP BY.
79pub(crate) fn rebase_expr(
80 expr: &Expr,
81 base_exprs: &[Expr],
82 plan: &LogicalPlan,
83) -> Result<Expr> {
84 expr.clone()
85 .transform_down(|nested_expr| {
86 if base_exprs.contains(&nested_expr) {
87 Ok(Transformed::yes(expr_as_column_expr(&nested_expr, plan)?))
88 } else {
89 Ok(Transformed::no(nested_expr))
90 }
91 })
92 .data()
93}
94
95#[derive(Debug, Clone, Copy, PartialEq, Eq)]
96pub(crate) enum CheckColumnsMustReferenceAggregatePurpose {

Callers 2

select_to_planMethod · 0.85
aggregateMethod · 0.85

Calls 5

expr_as_column_exprFunction · 0.85
transform_downMethod · 0.80
dataMethod · 0.45
cloneMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…