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.
This is a special version of to_binary that performs the same operation, but returns a NULL value instead of raising an error if the conversion cannot be performed.
For the corresponding Databricks SQL function, see try_to_binary function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.try_to_binary(col=<col>, format=<format>)
Parameters
| Parameter | Type | Description |
|---|---|---|
col |
pyspark.sql.Column or str |
Input column or strings. |
format |
pyspark.sql.Column or str, optional |
format to use to convert binary values. |
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([("abc",)], ["e"])
df.select(dbf.try_to_binary(df.e, dbf.lit("utf-8")).alias('r')).collect()
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([("414243",)], ["e"])
df.select(dbf.try_to_binary(df.e).alias('r')).collect()