pyspark.sql.functions.unbase64

pyspark.sql.functions.unbase64(col: ColumnOrName) → pyspark.sql.column.Column[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 str

target column to work on.

Returns
Column

encoded string value.

Examples

>>> df = spark.createDataFrame(["U3Bhcms=",
...                             "UHlTcGFyaw==",
...                             "UGFuZGFzIEFQSQ=="], "STRING")
>>> df.select(unbase64("value")).show()
+--------------------+
|     unbase64(value)|
+--------------------+
|    [53 70 61 72 6B]|
|[50 79 53 70 61 7...|
|[50 61 6E 64 61 7...|
+--------------------+