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

Function add_offset_to_expr

datafusion/physical-expr/src/physical_expr.rs:37–51  ·  view source on GitHub ↗

Adds the `offset` value to `Column` indices inside `expr`. This function is generally used during the update of the right table schema in join operations.

(
    expr: Arc<dyn PhysicalExpr>,
    offset: isize,
)

Source from the content-addressed store, hash-verified

35/// Adds the `offset` value to `Column` indices inside `expr`. This function is
36/// generally used during the update of the right table schema in join operations.
37pub fn add_offset_to_expr(
38 expr: Arc<dyn PhysicalExpr>,
39 offset: isize,
40) -> Result<Arc<dyn PhysicalExpr>> {
41 expr.transform_down(|e| match e.downcast_ref::<Column>() {
42 Some(col) => {
43 let Some(idx) = col.index().checked_add_signed(offset) else {
44 return plan_err!("Column index overflow");
45 };
46 Ok(Transformed::yes(Arc::new(Column::new(col.name(), idx))))
47 }
48 None => Ok(Transformed::no(e)),
49 })
50 .data()
51}
52
53/// This function is similar to the `contains` method of `Vec`. It finds
54/// whether `expr` is among `physical_exprs`.

Callers 5

try_with_offsetMethod · 0.85
joinMethod · 0.85

Calls 5

newFunction · 0.85
transform_downMethod · 0.80
dataMethod · 0.45
indexMethod · 0.45
nameMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…