Skip to content

Commit 0a64ef8

Browse files
authored
Make concat_ws_ignore_nulls private (#2718)
1 parent 91b49f4 commit 0a64ef8

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/snowflake/snowpark/functions.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3423,19 +3423,29 @@ def _concat_ws_ignore_nulls(sep: str, *cols: ColumnOrName) -> Column:
34233423
|Hello |
34243424
----------------------------------------------------
34253425
<BLANKLINE>
3426+
3427+
>>> df.select(_concat_ws_ignore_nulls('--', df.a, df.b, df.c)).show()
3428+
-----------------------------------------------------
3429+
|"CONCAT_WS_IGNORE_NULLS('--', ""A"",""B"",""C"")" |
3430+
-----------------------------------------------------
3431+
|Hello--World |
3432+
| |
3433+
|Hello |
3434+
-----------------------------------------------------
3435+
<BLANKLINE>
34263436
"""
34273437
# TODO: SNOW-1831917 create ast
34283438
columns = [_to_col_if_str(c, "_concat_ws_ignore_nulls") for c in cols]
34293439
names = ",".join([c.get_name() for c in columns])
34303440

3431-
input_column_array = array_construct_compact(*columns)
3432-
reduced_result = builtin("reduce")(
3441+
input_column_array = array_construct_compact(*columns, _emit_ast=False)
3442+
reduced_result = builtin("reduce", _emit_ast=False)(
34333443
input_column_array,
3434-
lit(""),
3444+
lit("", _emit_ast=False),
34353445
sql_expr(f"(l, r) -> l || '{sep}' || r"),
34363446
)
3437-
return substring(reduced_result, 2).alias(
3438-
f"CONCAT_WS_IGNORE_NULLS('{sep}', {names})"
3447+
return substring(reduced_result, len(sep) + 1, _emit_ast=False).alias(
3448+
f"CONCAT_WS_IGNORE_NULLS('{sep}', {names})", _emit_ast=False
34393449
)
34403450

34413451

0 commit comments

Comments
 (0)