From 0a64ef8b45d1f45e05bedd470d3d3fff44d66056 Mon Sep 17 00:00:00 2001 From: Afroz Alam Date: Mon, 9 Dec 2024 11:48:54 -0800 Subject: [PATCH] Make concat_ws_ignore_nulls private (#2718) --- src/snowflake/snowpark/functions.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/snowflake/snowpark/functions.py b/src/snowflake/snowpark/functions.py index 9977b452b77..29f2b40a7ad 100644 --- a/src/snowflake/snowpark/functions.py +++ b/src/snowflake/snowpark/functions.py @@ -3423,19 +3423,29 @@ def _concat_ws_ignore_nulls(sep: str, *cols: ColumnOrName) -> Column: |Hello | ---------------------------------------------------- + + >>> df.select(_concat_ws_ignore_nulls('--', df.a, df.b, df.c)).show() + ----------------------------------------------------- + |"CONCAT_WS_IGNORE_NULLS('--', ""A"",""B"",""C"")" | + ----------------------------------------------------- + |Hello--World | + | | + |Hello | + ----------------------------------------------------- + """ # TODO: SNOW-1831917 create ast columns = [_to_col_if_str(c, "_concat_ws_ignore_nulls") for c in cols] names = ",".join([c.get_name() for c in columns]) - input_column_array = array_construct_compact(*columns) - reduced_result = builtin("reduce")( + input_column_array = array_construct_compact(*columns, _emit_ast=False) + reduced_result = builtin("reduce", _emit_ast=False)( input_column_array, - lit(""), + lit("", _emit_ast=False), sql_expr(f"(l, r) -> l || '{sep}' || r"), ) - return substring(reduced_result, 2).alias( - f"CONCAT_WS_IGNORE_NULLS('{sep}', {names})" + return substring(reduced_result, len(sep) + 1, _emit_ast=False).alias( + f"CONCAT_WS_IGNORE_NULLS('{sep}', {names})", _emit_ast=False )