snowflake.snowpark.functions.call_udf¶
- snowflake.snowpark.functions.call_udf(udf_name: str, *args: Union[Column, None, bool, int, float, str, bytearray, Decimal, date, datetime, time, bytes, NaTType, float64, list, tuple, dict]) Column [source]¶
Calls a user-defined function (UDF) by name.
- Parameters:
udf_name – The name of UDF in Snowflake.
args –
Arguments can be in two types:
Column
, orBasic Python types, which are converted to Snowpark literals.
- Example::
>>> from snowflake.snowpark.types import IntegerType >>> udf_def = session.udf.register(lambda x, y: x + y, name="add_columns", input_types=[IntegerType(), IntegerType()], return_type=IntegerType(), replace=True) >>> df = session.create_dataframe([[1, 2]], schema=["a", "b"]) >>> df.select(call_udf("add_columns", col("a"), col("b"))).show() ------------------------------- |"ADD_COLUMNS(""A"", ""B"")" | ------------------------------- |3 | -------------------------------