5151
5252from snowflake .snowpark ._internal .analyzer import analyzer_utils
5353from snowflake .snowpark ._internal .analyzer .analyzer_utils import (
54- quote_name_without_upper_casing ,
5554 result_scan_statement ,
5655 schema_value_statement ,
57- unquote_if_quoted ,
5856)
5957from snowflake .snowpark ._internal .analyzer .binary_expression import And
6058from snowflake .snowpark ._internal .analyzer .expression import (
8785 has_invalid_projection_merge_functions ,
8886)
8987from snowflake .snowpark ._internal .utils import (
90- ALREADY_QUOTED ,
9188 ExprAliasUpdateDict ,
9289 is_sql_select_statement ,
9390 quote_name ,
@@ -1596,9 +1593,10 @@ def select(self, cols: List[Expression]) -> "SelectStatement":
15961593 # When describe reduction is on and the inner select already has resolved
15971594 # attributes, infer new.attributes for this outer select by reusing datatype and
15981595 # nullable from the subquery: (0) skip if parent column names collide, (1) index
1599- # attributes by normalized name, (2) walk new.projection, (3) only handle plain
1600- # columns or Alias(column), (4) resolve source via quoted-identifier-aware lookup,
1601- # (5) assign only if every output column was inferred (length matches projection).
1596+ # attributes by quote_name (Snowflake identifier rules; invalid delimited forms
1597+ # raise), (2) walk new.projection, (3) only handle plain columns or Alias(column),
1598+ # (4) resolve source via the same quote_name key lookup, (5) assign only if every
1599+ # output column was inferred (length matches projection).
16021600 if self ._session .reduce_describe_query_enabled and self .attributes is not None :
16031601 parent_attributes = self .attributes
16041602 projection = new .projection
@@ -1609,9 +1607,9 @@ def select(self, cols: List[Expression]) -> "SelectStatement":
16091607 attributes_by_normalized : Dict [str , Attribute ] = {}
16101608 collision = False
16111609 for attr in parent_attributes :
1612- key = _normalized_snowflake_identifier_key (attr .name )
1610+ key = quote_name (attr .name )
16131611 existing = attributes_by_normalized .get (key )
1614- # Skip: two parent columns normalize to the same key.
1612+ # Skip: two parent columns map to the same quote_name key.
16151613 if existing is not None and existing is not attr :
16161614 collision = True
16171615 break
@@ -1639,7 +1637,7 @@ def select(self, cols: List[Expression]) -> "SelectStatement":
16391637 inferred_attributes = []
16401638 break
16411639 source_attr = attributes_by_normalized .get (
1642- _normalized_snowflake_identifier_key (source_column_name )
1640+ quote_name (source_column_name )
16431641 )
16441642 # Skip: no parent column for this source name.
16451643 if source_attr is None :
@@ -2156,13 +2154,6 @@ class DeriveColumnDependencyError(Exception):
21562154 """When deriving column dependencies from the subquery."""
21572155
21582156
2159- def _normalized_snowflake_identifier_key (name : str ) -> str :
2160- """Canonical quoted key: delimited identifiers preserve case; unquoted follow Snowflake uppercasing."""
2161- if ALREADY_QUOTED .match (name ):
2162- return quote_name_without_upper_casing (unquote_if_quoted (name ))
2163- return quote_name (name )
2164-
2165-
21662157def parse_column_name (
21672158 column : Expression ,
21682159 analyzer : "Analyzer" ,
0 commit comments