File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4600,13 +4600,3 @@ def uuid_sql(self, expression: exp.Uuid) -> str:
46004600 return self .sql (result )
46014601
46024602 return super ().uuid_sql (expression )
4603-
4604- def identifier_sql (self , expression : exp .Identifier ) -> str :
4605- if expression .args .get ("identifier_func" ):
4606- parts = expression .name .split ("." )
4607- if len (parts ) > 1 :
4608- result : exp .Expr = exp .to_identifier (parts [0 ])
4609- for part in parts [1 :]:
4610- result = exp .Dot (this = result , expression = exp .to_identifier (part ))
4611- return self .sql (result )
4612- 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 @@ -1125,14 +1125,18 @@ def _parse_table(
11251125 def _fold_identifier_literal (self , arg : exp .Expr | None ) -> exp .Expr :
11261126 if arg and arg .is_string :
11271127 inner = arg .to_py ()
1128- if len (inner ) >= 2 and inner .startswith ('"' ) and inner .endswith ('"' ):
1129- return exp .Identifier (this = inner [1 :- 1 ], quoted = True , identifier_func = True )
1128+ try :
1129+ ident = exp .maybe_parse (inner , into = exp .Identifier )
1130+ if isinstance (ident , exp .Identifier ):
1131+ ident .set ("identifier_func" , True )
1132+ return ident
1133+ except Exception :
1134+ pass
11301135 return exp .Identifier (this = inner , identifier_func = True )
11311136 return self .expression (exp .Anonymous (this = "IDENTIFIER" , expressions = [arg ]))
11321137
11331138 def _parse_identifier_function (self ) -> exp .Expr :
1134- arg = self ._parse_string ()
1135- self ._match_r_paren ()
1139+ arg = self ._parse_string () or super ()._parse_id_var ()
11361140 return self ._fold_identifier_literal (arg )
11371141
11381142 def _parse_id_var (
You can’t perform that action at this time.
0 commit comments