@@ -85,7 +85,7 @@ def array_sort(expr: exp.Expression, asc=True) -> exp.Expression:
8585 return _apply_func_expr (expr , exp .ArraySort , expression = exp .Boolean (this = asc ))
8686
8787
88- def anonymous (expr : exp .Column , func : str , is_expr : bool = False ) -> exp .Expression :
88+ def anonymous (expr : exp .Column , func : str , is_expr : bool = False , dialect = None ) -> exp .Expression :
8989 """
9090
9191 This function used in cases where the sql functions are not available in sqlGlot expressions
@@ -104,6 +104,8 @@ def anonymous(expr: exp.Column, func: str, is_expr: bool = False) -> exp.Express
104104
105105 """
106106 if is_expr :
107+ if dialect :
108+ return exp .Column (this = func .format (expr .sql (dialect = dialect )))
107109 return exp .Column (this = func .format (expr ))
108110 is_terminal = isinstance (expr , exp .Column )
109111 new_expr = expr .copy ()
@@ -235,11 +237,17 @@ def _get_is_string(column_types_dict: dict[str, DataType], column_name: str) ->
235237 "universal" : {"default" : [partial (coalesce , default = '_null_recon_' , is_string = True ), partial (trim )]},
236238 "snowflake" : {exp .DataType .Type .ARRAY .value : [partial (array_to_string ), partial (array_sort )]},
237239 "oracle" : {
238- exp .DataType .Type .NCHAR .value : [partial (anonymous , func = "NVL(TRIM(TO_CHAR({})),'_null_recon_')" )],
239- exp .DataType .Type .NVARCHAR .value : [partial (anonymous , func = "NVL(TRIM(TO_CHAR({})),'_null_recon_')" )],
240+ exp .DataType .Type .NCHAR .value : [
241+ partial (anonymous , func = "NVL(TRIM(TO_CHAR({})),'_null_recon_')" , dialect = get_dialect ("oracle" ))
242+ ],
243+ exp .DataType .Type .NVARCHAR .value : [
244+ partial (anonymous , func = "NVL(TRIM(TO_CHAR({})),'_null_recon_')" , dialect = get_dialect ("oracle" ))
245+ ],
240246 },
241247 "databricks" : {
242- exp .DataType .Type .ARRAY .value : [partial (anonymous , func = "CONCAT_WS(',', SORT_ARRAY({}))" )],
248+ exp .DataType .Type .ARRAY .value : [
249+ partial (anonymous , func = "CONCAT_WS(',', SORT_ARRAY({}))" , dialect = get_dialect ("databricks" ))
250+ ],
243251 },
244252}
245253
@@ -250,7 +258,9 @@ def _get_is_string(column_types_dict: dict[str, DataType], column_name: str) ->
250258 target = sha256_partial ,
251259 ),
252260 get_dialect ("oracle" ): HashAlgoMapping (
253- source = partial (anonymous , func = "RAWTOHEX(STANDARD_HASH({}, 'SHA256'))" , is_expr = True ),
261+ source = partial (
262+ anonymous , func = "RAWTOHEX(STANDARD_HASH({}, 'SHA256'))" , is_expr = True , dialect = get_dialect ("oracle" )
263+ ),
254264 target = sha256_partial ,
255265 ),
256266 get_dialect ("databricks" ): HashAlgoMapping (
0 commit comments