@@ -132,7 +132,12 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
132132 nested_names,
133133 ) {
134134 match planner_result {
135- PlannerResult :: Planned ( expr) => return Ok ( expr) ,
135+ PlannerResult :: Planned ( expr) => {
136+ // sanity check on column
137+ schema
138+ . check_ambiguous_name ( qualifier, field. name ( ) ) ?;
139+ return Ok ( expr) ;
140+ }
136141 PlannerResult :: Original ( _args) => { }
137142 }
138143 }
@@ -143,6 +148,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
143148 }
144149 // found matching field with no spare identifier(s)
145150 Some ( ( field, qualifier, _nested_names) ) => {
151+ // sanity check on column
152+ schema. check_ambiguous_name ( qualifier, field. name ( ) ) ?;
146153 Ok ( Expr :: Column ( Column :: from ( ( qualifier, field) ) ) )
147154 }
148155 None => {
@@ -186,6 +193,9 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
186193 let s = & ids[ 0 ..ids. len ( ) ] ;
187194 // safe unwrap as s can never be empty or exceed the bounds
188195 let ( relation, column_name) = form_identifier ( s) . unwrap ( ) ;
196+ // sanity check on column
197+ schema
198+ . check_ambiguous_name ( relation. as_ref ( ) , column_name) ?;
189199 Ok ( Expr :: Column ( Column :: new ( relation, column_name) ) )
190200 }
191201 }
0 commit comments