You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix normalization of columns in JOIN ... USING. (#16560)
* Fix Column mgmt when parsing USING joins.
In SqlToRel::parse_join(), when handling JoinContraint::Using, the
identifiers are normalized using IdentNormalizer::normalize().
That normalization lower-cases unquoted identifiers, and keeps the case
otherwise (but not the quotes).
Until this commit, the normalized column names were passed to
LogicalPlanBuilder::join_using() as strings. When each goes through
LogicalPlanBuilder::normalize(), Column::From<String>() is called,
leading to Column::from_qualified_named(). As it gets an unqualified
column, it lower-cases it.
This means that if a join is USING("SOME_COLUMN_NAME"), we end up with a
Column { name: "some_column_name", ..}. In the end, the join fails, as
that lower-case column does not exist.
With this commit, SqlToRel::parse_join() calls Column::from_name() on
each normalized column and passed those to
LogicalPlanBuilder::join_using(). Downstream, in
LogicalPlanBuilder::normalize(), there is no need to create the Column
objects from strings, and the bug does not happen.
This fixes#16120.
* Remove genericity from LogicalPlanBuilder::join_using().
Until this commit, LogicalPlanBuilder::join_using() accepted using_keys:
Vec<impl Into<Column> + Clone>.
This commit removes this, only allowing Vec<Column>.
Motivation: passing e.g. Vec<String> for using_keys is bug-prone, as the
Strings can get (their case) modified when made into Column. That logic
is admissible with a common column name that can be qualified, but some
column names cannot (e.g. USING keys).
This commit changes the API. However, potential users can trivially fix
their code by calling Column::from/from_qualified_name on their
using_keys. This forces them to things about what their identifier
represent and that removes a class of potential bugs.
Additional bonus: shorter compilation time & binary size.
---------
Co-authored-by: Bruno Cauet <[email protected]>
0 commit comments