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

Method try_merge

datafusion/physical-expr/src/projection.rs:373–382  ·  view source on GitHub ↗

Apply another projection on top of this projection, returning the combined projection. For example, if this projection is `SELECT c@2 AS x, b@1 AS y, a@0 as z` and the other projection is `SELECT x@0 + 1 AS c1, y@1 + z@2 as c2`, we return a projection equivalent to `SELECT c@2 + 1 AS c1, b@1 + a@0 as c2`. # Example ```rust use datafusion_common::{Result, ScalarValue}; use datafusion_expr::Operat

(&self, other: &ProjectionExprs)

Source from the content-addressed store, hash-verified

371 /// This function returns an error if any expression in the `other` projection cannot be
372 /// applied on top of this projection.
373 pub fn try_merge(&self, other: &ProjectionExprs) -> Result<ProjectionExprs> {
374 let mut new_exprs = Vec::with_capacity(other.exprs.len());
375 for proj_expr in other.exprs.iter() {
376 new_exprs.push(ProjectionExpr {
377 expr: self.unproject_expr(&proj_expr.expr)?,
378 alias: proj_expr.alias.clone(),
379 });
380 }
381 Ok(ProjectionExprs::new(new_exprs))
382 }
383
384 /// Extract the column indices used in this projection.
385 /// For example, for a projection `SELECT a AS x, b + 1 AS y`, where `a` is at index 0 and `b` is at index 1,

Calls 6

newFunction · 0.85
unproject_exprMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45
cloneMethod · 0.45

Tested by 6

try_merge_errorFunction · 0.64