नोट
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप साइन इन करने या निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
इस पेज तक पहुँच के लिए प्रमाणन की आवश्यकता होती है. आप निर्देशिकाओं को बदलने का प्रयास कर सकते हैं.
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()