File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1794,7 +1794,6 @@ class Identifier(Expression):
17941794 "quoted" : False ,
17951795 "global_" : False ,
17961796 "temporary" : False ,
1797- "identifier_func" : False ,
17981797 }
17991798 is_primitive = True
18001799 _hash_raw_args = True
@@ -1808,6 +1807,10 @@ def output_name(self) -> str:
18081807 return self .name
18091808
18101809
1810+ class DynamicIdentifier (Expression ):
1811+ arg_types = {"this" : True }
1812+
1813+
18111814class Opclass (Expression ):
18121815 arg_types = {"this" : True , "expression" : True }
18131816
Original file line number Diff line number Diff line change @@ -1951,6 +1951,12 @@ def index_sql(self, expression: exp.Index) -> str:
19511951 params = self .sql (expression , "params" )
19521952 return f"{ unique } { primary } { amp } { index } { name } { table } { params } "
19531953
1954+ def dynamicidentifier_sql (self , expression : exp .DynamicIdentifier ) -> str :
1955+ this = expression .this
1956+ if this and this .is_string :
1957+ return this .name
1958+ return self .func ("IDENTIFIER" , this )
1959+
19541960 def identifier_sql (self , expression : exp .Identifier ) -> str :
19551961 text = expression .name
19561962 lower = text .lower ()
Original file line number Diff line number Diff line change @@ -616,21 +616,8 @@ class SnowflakeGenerator(generator.Generator):
616616 ),
617617 }
618618
619- def identifier_sql (self , expression : exp .Identifier ) -> str :
620- if expression .args .get ("identifier_func" ):
621- name = super ().identifier_sql (expression ) if expression .quoted else expression .name
622- return self .func ("IDENTIFIER" , exp .Literal .string (name ))
623- return super ().identifier_sql (expression )
624-
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 )
619+ def dynamicidentifier_sql (self , expression : exp .DynamicIdentifier ) -> str :
620+ return self .func ("IDENTIFIER" , expression .this )
634621
635622 def sortarray_sql (self , expression : exp .SortArray ) -> str :
636623 asc = expression .args .get ("asc" )
Original file line number Diff line number Diff line change @@ -1144,17 +1144,7 @@ def _parse_table(
11441144 return table
11451145
11461146 def _fold_identifier_literal (self , arg : exp .Expr | None ) -> exp .Expr :
1147- if arg and arg .is_string :
1148- inner = arg .to_py ()
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
1156- return exp .Identifier (this = inner , identifier_func = True )
1157- return self .expression (exp .Anonymous (this = "IDENTIFIER" , expressions = [arg ]))
1147+ return self .expression (exp .DynamicIdentifier (this = arg ))
11581148
11591149 def _parse_identifier_function (self ) -> exp .Expr :
11601150 arg = self ._parse_string () or super ()._parse_id_var ()
You can’t perform that action at this time.
0 commit comments