diff --git a/datafusion/sql/src/expr/mod.rs b/datafusion/sql/src/expr/mod.rs index 6e975d8557dc..c79c6358be36 100644 --- a/datafusion/sql/src/expr/mod.rs +++ b/datafusion/sql/src/expr/mod.rs @@ -27,7 +27,7 @@ use sqlparser::ast::{ use datafusion_common::{ internal_datafusion_err, internal_err, not_impl_err, plan_err, DFSchema, Result, - ScalarValue, TableReference, + ScalarValue, }; use datafusion_expr::expr::ScalarFunction; use datafusion_expr::expr::{InList, WildcardOptions}; @@ -562,7 +562,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { options: WildcardOptions::default(), }), SQLExpr::QualifiedWildcard(object_name) => Ok(Expr::Wildcard { - qualifier: Some(TableReference::from(object_name.to_string())), + qualifier: Some(self.object_name_to_table_reference(object_name)?), options: WildcardOptions::default(), }), SQLExpr::Tuple(values) => self.parse_tuple(schema, planner_context, values), diff --git a/datafusion/sql/src/select.rs b/datafusion/sql/src/select.rs index 8a26671fcb6c..500932b46809 100644 --- a/datafusion/sql/src/select.rs +++ b/datafusion/sql/src/select.rs @@ -18,9 +18,7 @@ use std::collections::HashSet; use std::sync::Arc; -use crate::planner::{ - idents_to_table_reference, ContextProvider, PlannerContext, SqlToRel, -}; +use crate::planner::{ContextProvider, PlannerContext, SqlToRel}; use crate::utils::{ check_columns_satisfy_exprs, extract_aliases, rebase_expr, resolve_aliases_to_exprs, resolve_columns, resolve_positions_to_exprs, transform_bottom_unnests, @@ -590,7 +588,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { } SelectItem::QualifiedWildcard(object_name, options) => { Self::check_wildcard_options(&options)?; - let qualifier = idents_to_table_reference(object_name.0, false)?; + let qualifier = self.object_name_to_table_reference(object_name)?; let planned_options = self.plan_wildcard_options( plan, empty_from, diff --git a/datafusion/sqllogictest/test_files/wildcard.slt b/datafusion/sqllogictest/test_files/wildcard.slt index 9285bdbf2306..7c076f040feb 100644 --- a/datafusion/sqllogictest/test_files/wildcard.slt +++ b/datafusion/sqllogictest/test_files/wildcard.slt @@ -108,6 +108,31 @@ SELECT t1.*, tb2.* FROM t1 JOIN t2 tb2 ON t2_id = t1_id ORDER BY t1_id statement error Error during planning: Invalid qualifier agg SELECT agg.* FROM aggregate_simple ORDER BY c1 +# select_upper_case_qualified_wildcard +query ITI +SELECT PUBLIC.t1.* FROM PUBLIC.t1 +---- +11 a 1 +22 b 2 +33 c 3 +44 d 4 + +query ITI +SELECT PUBLIC.t1.* FROM public.t1 +---- +11 a 1 +22 b 2 +33 c 3 +44 d 4 + +query ITI +SELECT public.t1.* FROM PUBLIC.t1 +---- +11 a 1 +22 b 2 +33 c 3 +44 d 4 + ######## # Clean up after the test ########