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

snowflake.snowpark.functions.translate

snowflake.snowpark.functions.translate(src: ColumnOrName, source_alphabet: ColumnOrName, target_alphabet: ColumnOrName) Column[source]

Translates src from the characters in source_alphabet to the characters in target_alphabet. Each character matching a character at position i in the source_alphabet is replaced with the character at position i in the target_alphabet. If target_alphabet is shorter, and there is no corresponding character the character is omitted. target_alphabet can not be longer than source_alphabet.

Example:

>>> df = session.create_dataframe(["abcdef", "abba"], schema=["a"])
>>> df.select(translate(col("a"), lit("abc"), lit("ABC")).as_("ans")).collect()
[Row(ANS='ABCdef'), Row(ANS='ABBA')]

>>> df = session.create_dataframe(["file with spaces.txt", "\ttest"], schema=["a"])
>>> df.select(translate(col("a"), lit(" \t"), lit("_")).as_("ans")).collect()
[Row(ANS='file_with_spaces.txt'), Row(ANS='test')]
Copy