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 @@ -1945,6 +1945,12 @@ def index_sql(self, expression: exp.Index) -> str:
19451945 params = self .sql (expression , "params" )
19461946 return f"{ unique } { primary } { amp } { index } { name } { table } { params } "
19471947
1948+ def dynamicidentifier_sql (self , expression : exp .DynamicIdentifier ) -> str :
1949+ this = expression .this
1950+ if this and this .is_string :
1951+ return this .name
1952+ return self .func ("IDENTIFIER" , this )
1953+
19481954 def identifier_sql (self , expression : exp .Identifier ) -> str :
19491955 text = expression .name
19501956 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 @@ -1123,17 +1123,7 @@ def _parse_table(
11231123 return table
11241124
11251125 def _fold_identifier_literal (self , arg : exp .Expr | None ) -> exp .Expr :
1126- if arg and arg .is_string :
1127- inner = arg .to_py ()
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
1135- return exp .Identifier (this = inner , identifier_func = True )
1136- return self .expression (exp .Anonymous (this = "IDENTIFIER" , expressions = [arg ]))
1126+ return self .expression (exp .DynamicIdentifier (this = arg ))
11371127
11381128 def _parse_identifier_function (self ) -> exp .Expr :
11391129 arg = self ._parse_string () or super ()._parse_id_var ()
You can’t perform that action at this time.
0 commit comments