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

Method rewrite_partial_qualifier

datafusion/sql/src/expr/mod.rs:182–201  ·  view source on GitHub ↗

Rewrite aliases which are not-complete (e.g. ones that only include only table qualifier in a schema.table qualified relation)

(&self, expr: Expr, schema: &DFSchema)

Source from the content-addressed store, hash-verified

180
181 /// Rewrite aliases which are not-complete (e.g. ones that only include only table qualifier in a schema.table qualified relation)
182 fn rewrite_partial_qualifier(&self, expr: Expr, schema: &DFSchema) -> Expr {
183 match expr {
184 Expr::Column(col) => match &col.relation {
185 Some(q) => {
186 match schema.iter().find(|(qualifier, field)| match qualifier {
187 Some(field_q) => {
188 field.name() == &col.name
189 && field_q.to_string().ends_with(&format!(".{q}"))
190 }
191 _ => false,
192 }) {
193 Some((qualifier, df_field)) => Expr::from((qualifier, df_field)),
194 None => Expr::Column(col),
195 }
196 }
197 None => Expr::Column(col),
198 },
199 _ => expr,
200 }
201 }
202
203 /// Internal implementation. Use
204 /// [`Self::sql_expr_to_logical_expr`] to plan exprs.

Callers 2

sql_to_exprMethod · 0.80

Calls 4

ColumnClass · 0.50
iterMethod · 0.45
nameMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected