Skip to content

Commit 48d395a

Browse files
authored
Remove unnecessary DFSchema::check_ambiguous_name (#12805)
1 parent a769025 commit 48d395a

File tree

2 files changed

+0
-35
lines changed

2 files changed

+0
-35
lines changed

datafusion/common/src/dfschema.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -406,33 +406,6 @@ impl DFSchema {
406406
}
407407
}
408408

409-
/// Check whether the column reference is ambiguous
410-
pub fn check_ambiguous_name(
411-
&self,
412-
qualifier: Option<&TableReference>,
413-
name: &str,
414-
) -> Result<()> {
415-
let count = self
416-
.iter()
417-
.filter(|(field_q, f)| match (field_q, qualifier) {
418-
(Some(q1), Some(q2)) => q1.resolved_eq(q2) && f.name() == name,
419-
(None, None) => f.name() == name,
420-
_ => false,
421-
})
422-
.take(2)
423-
.count();
424-
if count > 1 {
425-
_schema_err!(SchemaError::AmbiguousReference {
426-
field: Column {
427-
relation: None,
428-
name: name.to_string(),
429-
},
430-
})
431-
} else {
432-
Ok(())
433-
}
434-
}
435-
436409
/// Find the qualified field with the given name
437410
pub fn qualified_field_with_name(
438411
&self,

datafusion/sql/src/expr/identifier.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
126126
) {
127127
match planner_result {
128128
PlannerResult::Planned(expr) => {
129-
// sanity check on column
130-
schema
131-
.check_ambiguous_name(qualifier, field.name())?;
132129
return Ok(expr);
133130
}
134131
PlannerResult::Original(_args) => {}
@@ -139,8 +136,6 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
139136
}
140137
// found matching field with no spare identifier(s)
141138
Some((field, qualifier, _nested_names)) => {
142-
// sanity check on column
143-
schema.check_ambiguous_name(qualifier, field.name())?;
144139
Ok(Expr::Column(Column::from((qualifier, field))))
145140
}
146141
None => {
@@ -184,9 +179,6 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
184179
let s = &ids[0..ids.len()];
185180
// safe unwrap as s can never be empty or exceed the bounds
186181
let (relation, column_name) = form_identifier(s).unwrap();
187-
// sanity check on column
188-
schema
189-
.check_ambiguous_name(relation.as_ref(), column_name)?;
190182
Ok(Expr::Column(Column::new(relation, column_name)))
191183
}
192184
}

0 commit comments

Comments
 (0)