Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Returns the decompressed value of expr using Zstandard. Supports data compressed in both single-pass mode and streaming mode. On decompression failure, it returns NULL.
Syntax
from pyspark.sql import functions as dbf
dbf.try_zstd_decompress(input=<input>)
Parameters
| Parameter | Type | Description |
|---|---|---|
input |
pyspark.sql.Column or str |
The binary value to decompress. |
Returns
pyspark.sql.Column: A new column that contains an uncompressed value.
Examples
Example 1: Decompress data using Zstandard
from pyspark.sql import functions as dbf
df = spark.createDataFrame([("KLUv/SCCpQAAaEFwYWNoZSBTcGFyayABABLS+QU=",)], ["input"])
df.select(dbf.try_zstd_decompress(dbf.unbase64(df.input)).cast("string").alias("result")).show(truncate=False)
+----------------------------------------------------------------------------------------------------------------------------------+
|result |
+----------------------------------------------------------------------------------------------------------------------------------+
|Apache Spark Apache Spark Apache Spark Apache Spark Apache Spark Apache Spark Apache Spark Apache Spark Apache Spark Apache Spark |
+----------------------------------------------------------------------------------------------------------------------------------+
Example 2: Decompress invalid input
from pyspark.sql import functions as dbf
df = spark.createDataFrame([("invalid input",)], ["input"])
df.select(dbf.try_zstd_decompress(dbf.unbase64(df.input)).cast("string").alias("result")).show(truncate=False)
+------+
|result|
+------+
|NULL |
+------+