pyspark.sql.functions.unbase64#

pyspark.sql.functions.unbase64(col)[source]#

Decodes a BASE64 encoded string column and returns it as a binary column.

New in version 1.5.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or column name

target column to work on.

Returns
Column

encoded string value.

Examples

>>> from pyspark.sql import functions as sf
>>> df = spark.createDataFrame(["U3Bhcms=", "UHlTcGFyaw==", "UGFuZGFzIEFQSQ=="], "STRING")
>>> df.select("*", sf.unbase64("value")).show(truncate=False)
+----------------+-------------------------------+
|value           |unbase64(value)                |
+----------------+-------------------------------+
|U3Bhcms=        |[53 70 61 72 6B]               |
|UHlTcGFyaw==    |[50 79 53 70 61 72 6B]         |
|UGFuZGFzIEFQSQ==|[50 61 6E 64 61 73 20 41 50 49]|
+----------------+-------------------------------+