Function datafusion_substrait::logical_plan::producer::to_substrait_rex
source · pub fn to_substrait_rex(
ctx: &SessionContext,
expr: &Expr,
schema: &DFSchemaRef,
col_ref_offset: usize,
extensions: &mut Extensions,
) -> Result<Expression>
Expand description
Convert DataFusion Expr to Substrait Rex
§Arguments
expr
- DataFusion expression to be parse into a Substrait expressionschema
- DataFusion input schema for looking up field qualifierscol_ref_offset
- Offset for calculating Substrait field reference indices. This should only be set by caller with more than one input relations i.e. Join. Substrait expects one set of indices when joining two relations. Let’s sayleft
andright
havem
andn
columns, respectively. Theright
relation will have column indices from0
ton-1
, however, Substrait will expect theright
indices to be offset by theleft
. This means Substrait will expect to evaluate the join condition expression on indices [0 .. n-1, n .. n+m-1]. For example:SELECT * FROM t1 JOIN t2 ON t1.c1 = t2.c0;
where t1 consists of columns [c0, c1, c2], and t2 = columns [c0, c1] the join condition should becomecol_ref(1) = col_ref(3 + 0)
, where3
is the number ofleft
columns (col_ref_offset
) and0
is the index of the join key column fromright
extensions
- Substrait extension info. Contains registered function information