snowflake.snowpark.functions.as_boolean

snowflake.snowpark.functions.as_boolean(variant: Union[snowflake.snowpark.column.Column, str]) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.40.0/src/snowflake/snowpark/_functions/scalar_functions.py#L795-L816)

Casts a VARIANT value to a boolean.

Parameters:

variant (ColumnOrName) – A Column or column name containing VARIANT values to be cast to boolean.

Returns:

ColumnL The boolean values cast from the VARIANT input.

Example::
>>> from snowflake.snowpark.functions import to_variant, to_boolean
>>> df = session.create_dataframe([
...     [True],
...     [False]
... ], schema=["a"])
>>> df.select(as_boolean(to_variant(to_boolean(df["a"]))).alias("result")).collect()
[Row(RESULT=True), Row(RESULT=False)]
Copy
Language: English