diff --git a/datafusion/src/logical_plan/dfschema.rs b/datafusion/src/logical_plan/dfschema.rs index b46e067a268b..b4d864f55ebd 100644 --- a/datafusion/src/logical_plan/dfschema.rs +++ b/datafusion/src/logical_plan/dfschema.rs @@ -158,8 +158,8 @@ impl DFSchema { } } Err(DataFusionError::Plan(format!( - "No field matches column '{}'", - col, + "No field matches column '{}'. Available fields: {}", + col, self ))) } diff --git a/datafusion/src/logical_plan/expr.rs b/datafusion/src/logical_plan/expr.rs index 622b7a4ec4ae..ed5cb113b960 100644 --- a/datafusion/src/logical_plan/expr.rs +++ b/datafusion/src/logical_plan/expr.rs @@ -83,7 +83,12 @@ impl Column { } } - /// Normalize Column with qualifier based on provided dataframe schemas. + /// Normalizes `self` if is unqualified (has no relation name) + /// with an explicit qualifier from the first matching input + /// schemas. + /// + /// For example, `foo` will be normalized to `t.foo` if there is a + /// column named `foo` in a relation named `t` found in `schemas` pub fn normalize(self, schemas: &[&DFSchemaRef]) -> Result { if self.relation.is_some() { return Ok(self); @@ -1113,7 +1118,8 @@ pub fn columnize_expr(e: Expr, input_schema: &DFSchema) -> Expr { } } -/// Recursively normalize all Column expressions in a given expression tree +/// Recursively call [`Column::normalize`] on all Column expressions +/// in the `expr` expression tree. pub fn normalize_col(e: Expr, schemas: &[&DFSchemaRef]) -> Result { struct ColumnNormalizer<'a, 'b> { schemas: &'a [&'b DFSchemaRef],