snowflake.snowpark.functions.try_base64_decode_string¶
- snowflake.snowpark.functions.try_base64_decode_string(input_expr: Union[snowflake.snowpark.column.Column, str], alphabet: Union[snowflake.snowpark.column.Column, str] = None) Column[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.43.0/src/snowflake/snowpark/_functions/scalar_functions.py#L4328-L4360)¶
Decodes a base64-encoded string and returns the result. If the input is not a valid base64-encoded string, returns NULL instead of raising an error.
- Parameters:
input_expr (ColumnOrName) – A base64-encoded string to decode.
alphabet (ColumnOrName, optional) – The base64 alphabet to use for decoding. If not specified, uses the standard base64 alphabet.
- Returns:
The decoded string, or NULL if the input is not valid base64.
- Return type:
- Examples::
>>> df = session.create_dataframe([["SEVMTE8="]], schema=["encoded"]) >>> df.select(try_base64_decode_string(df["encoded"]).alias('result')).collect() [Row(RESULT='HELLO')]
>>> df = session.create_dataframe([["invalid_base64"]], schema=["encoded"]) >>> df.select(try_base64_decode_string(df["encoded"]).alias('result')).collect() [Row(RESULT=None)]
>>> df = session.create_dataframe([["SEVMTE8="]], schema=["encoded"]) >>> df.select(try_base64_decode_string(df["encoded"], lit('$')).alias('result')).collect() [Row(RESULT='HELLO')]