Skip to content

Commit

Permalink
Make concat_ws_ignore_nulls private
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-aalam authored and sfc-gh-aling committed Dec 5, 2024
1 parent b818120 commit bf4641f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
- Added support for following functions in `functions.py`:
- `size` to get size of array, object, or map columns.
- `collect_list` an alias of `array_agg`.
- `concat_ws_ignore_nulls` to concatenate strings with a separator, ignoring null values.
- `substring` makes `len` argument optional.
- Added parameter `ast_enabled` to session for internal usage (default: `False`).

Expand Down
1 change: 0 additions & 1 deletion docs/source/snowpark/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ Functions
column
concat
concat_ws
concat_ws_ignore_nulls
contains
convert_timezone
corr
Expand Down
17 changes: 7 additions & 10 deletions src/snowflake/snowpark/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3402,10 +3402,7 @@ def concat_ws(*cols: ColumnOrName, _emit_ast: bool = True) -> Column:
return builtin("concat_ws", _emit_ast=_emit_ast)(*columns)


@publicapi
def concat_ws_ignore_nulls(
sep: str, *cols: ColumnOrName, _emit_ast: bool = True
) -> Column:
def _concat_ws_ignore_nulls(sep: str, *cols: ColumnOrName) -> Column:
"""Concatenates two or more strings, or concatenates two or more binary values. Null values are ignored.
Args:
Expand All @@ -3431,14 +3428,14 @@ def concat_ws_ignore_nulls(
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, _emit_ast=False)
reduced_result = builtin("reduce", _emit_ast=False)(
input_column_array = array_construct_compact(*columns)
reduced_result = builtin("reduce")(
input_column_array,
lit("", _emit_ast=False),
sql_expr(f"(l, r) -> l || '{sep}' || r", _emit_ast=False),
lit(""),
sql_expr(f"(l, r) -> l || '{sep}' || r"),
)
return substring(reduced_result, 2, _emit_ast=False).alias(
f"CONCAT_WS_IGNORE_NULLS('{sep}', {names})", _emit_ast=False
return substring(reduced_result, 2).alias(
f"CONCAT_WS_IGNORE_NULLS('{sep}', {names})"
)


Expand Down

0 comments on commit bf4641f

Please sign in to comment.