File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4599,13 +4599,3 @@ def uuid_sql(self, expression: exp.Uuid) -> str:
45994599 return self .sql (result )
46004600
46014601 return super ().uuid_sql (expression )
4602-
4603- def identifier_sql (self , expression : exp .Identifier ) -> str :
4604- if expression .args .get ("identifier_func" ):
4605- parts = expression .name .split ("." )
4606- if len (parts ) > 1 :
4607- result : exp .Expr = exp .to_identifier (parts [0 ])
4608- for part in parts [1 :]:
4609- result = exp .Dot (this = result , expression = exp .to_identifier (part ))
4610- return self .sql (result )
4611- return super ().identifier_sql (expression )
Original file line number Diff line number Diff line change @@ -618,10 +618,20 @@ class SnowflakeGenerator(generator.Generator):
618618
619619 def identifier_sql (self , expression : exp .Identifier ) -> str :
620620 if expression .args .get ("identifier_func" ):
621- name = f'" { expression . name } "' if expression .quoted else expression .name
621+ name = super (). identifier_sql ( expression ) if expression .quoted else expression .name
622622 return self .func ("IDENTIFIER" , exp .Literal .string (name ))
623623 return super ().identifier_sql (expression )
624624
625+ def column_sql (self , expression : exp .Column ) -> str :
626+ if (
627+ expression .table
628+ and isinstance (expression .this , exp .Identifier )
629+ and expression .this .args .get ("identifier_func" )
630+ ):
631+ expression = expression .copy ()
632+ expression .this .set ("identifier_func" , False )
633+ return super ().column_sql (expression )
634+
625635 def sortarray_sql (self , expression : exp .SortArray ) -> str :
626636 asc = expression .args .get ("asc" )
627637 nulls_first = expression .args .get ("nulls_first" )
Original file line number Diff line number Diff line change @@ -1146,14 +1146,18 @@ def _parse_table(
11461146 def _fold_identifier_literal (self , arg : exp .Expr | None ) -> exp .Expr :
11471147 if arg and arg .is_string :
11481148 inner = arg .to_py ()
1149- if len (inner ) >= 2 and inner .startswith ('"' ) and inner .endswith ('"' ):
1150- return exp .Identifier (this = inner [1 :- 1 ], quoted = True , identifier_func = True )
1149+ try :
1150+ ident = exp .maybe_parse (inner , into = exp .Identifier )
1151+ if isinstance (ident , exp .Identifier ):
1152+ ident .set ("identifier_func" , True )
1153+ return ident
1154+ except Exception :
1155+ pass
11511156 return exp .Identifier (this = inner , identifier_func = True )
11521157 return self .expression (exp .Anonymous (this = "IDENTIFIER" , expressions = [arg ]))
11531158
11541159 def _parse_identifier_function (self ) -> exp .Expr :
1155- arg = self ._parse_string ()
1156- self ._match_r_paren ()
1160+ arg = self ._parse_string () or super ()._parse_id_var ()
11571161 return self ._fold_identifier_literal (arg )
11581162
11591163 def _parse_id_var (
You can’t perform that action at this time.
0 commit comments