Skip to content

Commit

Permalink
fix: upper case qualifier wildcard bug (#12426)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonLi-cn committed Sep 12, 2024
1 parent b9dabdb commit f7efd2d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
4 changes: 2 additions & 2 deletions datafusion/sql/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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),
Expand Down
6 changes: 2 additions & 4 deletions datafusion/sql/src/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
25 changes: 25 additions & 0 deletions datafusion/sqllogictest/test_files/wildcard.slt
Original file line number Diff line number Diff line change
Expand Up @@ -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
########
Expand Down

0 comments on commit f7efd2d

Please sign in to comment.