Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Returns schema in the SQL format of a variant.
Syntax
from pyspark.sql import functions as sf
sf.schema_of_variant(v)
Parameters
| Parameter | Type | Description |
|---|---|---|
v |
pyspark.sql.Column or str |
A variant column or column name. |
Returns
pyspark.sql.Column: a string column representing the variant schema
Examples
from pyspark.sql import functions as sf
df = spark.createDataFrame([ {'json': '''{ "a" : 1 }'''} ])
df.select(sf.schema_of_variant(sf.parse_json(df.json)).alias("r")).collect()
[Row(r='OBJECT<a: BIGINT>')]