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

Function rewrite_placeholder

datafusion/expr/src/expr.rs:2883–2902  ·  view source on GitHub ↗

Modifies expr to match the DataType, metadata, and nullability of other if it is a placeholder with previously unspecified type information (i.e., most placeholders)

(expr: &mut Expr, other: &Expr, schema: &DFSchema)

Source from the content-addressed store, hash-verified

2881// Modifies expr to match the DataType, metadata, and nullability of other if it is
2882// a placeholder with previously unspecified type information (i.e., most placeholders)
2883fn rewrite_placeholder(expr: &mut Expr, other: &Expr, schema: &DFSchema) -> Result<()> {
2884 if let Expr::Placeholder(Placeholder { id: _, field }) = expr
2885 && field.is_none()
2886 {
2887 let other_field = other.to_field(schema);
2888 match other_field {
2889 Err(e) => {
2890 Err(e.context(format!(
2891 "Can not find type of {other} needed to infer type of {expr}"
2892 )))?;
2893 }
2894 Ok((_, other_field)) => {
2895 // We can't infer the nullability of the future parameter that might
2896 // be bound, so ensure this is set to true
2897 *field = Some(other_field.as_ref().clone().with_nullable(true).into());
2898 }
2899 }
2900 };
2901 Ok(())
2902}
2903
2904#[macro_export]
2905macro_rules! expr_vec_fmt {

Callers 1

Calls 7

is_noneMethod · 0.80
to_fieldMethod · 0.80
contextMethod · 0.80
intoMethod · 0.45
with_nullableMethod · 0.45
cloneMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…