@@ -54,9 +54,9 @@ use datafusion_expr::{
5454
5555use indexmap:: IndexMap ;
5656use sqlparser:: ast:: {
57- Distinct , Expr as SQLExpr , GroupByExpr , NamedWindowExpr , OrderBy , RenameSelectItem ,
58- SelectItemQualifiedWildcardKind , WildcardAdditionalOptions , WindowType ,
59- visit_expressions_mut,
57+ Distinct , ExcludeSelectItem , Expr as SQLExpr , GroupByExpr , NamedWindowExpr ,
58+ ObjectNamePart , OrderBy , RenameSelectItem , SelectItemQualifiedWildcardKind ,
59+ WildcardAdditionalOptions , WindowType , visit_expressions_mut,
6060} ;
6161use sqlparser:: ast:: { NamedWindowDefinition , Select , SelectItem , TableWithJoins } ;
6262
@@ -1246,6 +1246,22 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
12461246 }
12471247 }
12481248
1249+ pub ( crate ) fn normalize_wildcard_exclude (
1250+ & self ,
1251+ mut exclude : ExcludeSelectItem ,
1252+ ) -> ExcludeSelectItem {
1253+ let names = match & mut exclude {
1254+ ExcludeSelectItem :: Single ( name) => std:: slice:: from_mut ( name) ,
1255+ ExcludeSelectItem :: Multiple ( names) => names,
1256+ } ;
1257+ for name in names {
1258+ if let [ ObjectNamePart :: Identifier ( ident) ] = name. 0 . as_mut_slice ( ) {
1259+ ident. value = self . ident_normalizer . normalize ( ident. clone ( ) ) ;
1260+ }
1261+ }
1262+ exclude
1263+ }
1264+
12491265 /// If there is a REPLACE statement in the projected expression in the form of
12501266 /// "REPLACE (some_column_within_an_expr AS some_column)", we should plan the
12511267 /// replace expressions first.
@@ -1256,6 +1272,9 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
12561272 planner_context : & mut PlannerContext ,
12571273 options : WildcardAdditionalOptions ,
12581274 ) -> Result < WildcardOptions > {
1275+ let exclude = options
1276+ . opt_exclude
1277+ . map ( |exclude| self . normalize_wildcard_exclude ( exclude) ) ;
12591278 let rename = options. opt_rename . map ( |mut rename| {
12601279 let items = match & mut rename {
12611280 RenameSelectItem :: Single ( item) => std:: slice:: from_mut ( item) ,
@@ -1269,7 +1288,7 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
12691288 } ) ;
12701289 let planned_option = WildcardOptions {
12711290 ilike : options. opt_ilike ,
1272- exclude : options . opt_exclude ,
1291+ exclude,
12731292 except : options. opt_except ,
12741293 replace : None ,
12751294 rename,
0 commit comments