@@ -3397,7 +3397,13 @@ def convert_concat_args(self, expression: exp.Func) -> list[exp.Expr]:
33973397 if self .dialect .STRICT_STRING_CONCAT and expression .args .get ("safe" ):
33983398 args = [exp .cast (e , exp .DType .TEXT ) for e in args ]
33993399
3400- if not self .dialect .CONCAT_COALESCE and expression .args .get ("coalesce" ):
3400+ concat_coalesce = (
3401+ self .dialect .CONCAT_WS_COALESCE
3402+ if isinstance (expression , exp .ConcatWs )
3403+ else self .dialect .CONCAT_COALESCE
3404+ )
3405+
3406+ if not concat_coalesce and expression .args .get ("coalesce" ):
34013407
34023408 def _wrap_with_coalesce (e : exp .Expr ) -> exp .Expr :
34033409 if not e .type :
@@ -3432,8 +3438,8 @@ def concat_sql(self, expression: exp.Concat) -> str:
34323438 return self .func ("CONCAT" , * expressions )
34333439
34343440 def concatws_sql (self , expression : exp .ConcatWs ) -> str :
3435- if self .dialect .CONCAT_COALESCE and not expression .args .get ("coalesce" ):
3436- # Dialect's CONCAT_WS function coalesces NULLs to empty strings , but the expression does not.
3441+ if self .dialect .CONCAT_WS_COALESCE and not expression .args .get ("coalesce" ):
3442+ # Dialect's CONCAT_WS function skips NULL args , but the expression does not.
34373443 # Wrap the entire call in a CASE expression that returns NULL if any input IS NULL.
34383444 all_args = expression .expressions
34393445 expression .set ("coalesce" , True )
0 commit comments