You are viewing documentation about an older version (1.12.1). View latest version

snowflake.snowpark.functions.as_varchar

snowflake.snowpark.functions.as_varchar(variant: Union[Column, str]) Column[source]

Casts a VARIANT value to a string.

Example:

>>> from snowflake.snowpark.functions import as_varchar, to_variant
>>> df = session.sql("select 'some string' as char")
>>> df.char_v = to_variant(df.char)
>>> df.select(df.char_v.as_("char")).collect() == df.select(df.char).collect()
False
>>> df.select(as_varchar(df.char_v).as_("char")).collect() == df.select(df.char).collect()
True
Copy