pub fn update_expr(
expr: &Arc<dyn PhysicalExpr>,
projected_exprs: &[ProjectionExpr],
unproject: bool,
) -> Result<Option<Arc<dyn PhysicalExpr>>>Expand description
The function projects / unprojects an expression with respect to set of projection expressions.
See also ProjectionExprs::unproject_expr and ProjectionExprs::project_expr
-
When
unprojectistrue:Rewrites an expression with respect to the projection expressions, effectively “unprojecting” it to reference the original input columns.
For example, given
- the expressions
a@1 + b@2andc@0 - and projection expressions
c@2, a@0, b@1
Then
a@1 + b@2becomesa@0 + b@1c@0becomesc@2
- the expressions
-
When
unprojectisfalse:Rewrites the expression to reference the projected expressions, effectively “projecting” it. The resulting expression will reference the indices as they appear in the projection.
If the expression cannot be rewritten after the projection, it returns
None.For example, given
- the expressions
c@0,a@1andb@2 - the projection
a@1 as a, c@0 as c_new,
Then
c@0becomesc_new@1a@1becomesa@0b@2results inNonesince the projection does not includeb.
- the expressions
§Errors
This function returns an error if unproject is true and if any expression references
an index that is out of bounds for projected_exprs.
For example:
exprisa@3projected_exprsis [a@0,b@1]
In this case, a@3 references index 3, which is out of bounds for projected_exprs (which has length 2).