pyspark.sql.functions.schema_of_variant#

pyspark.sql.functions.schema_of_variant(v)[source]#

Returns schema in the SQL format of a variant.

New in version 4.0.0.

Parameters
vColumn or str

a variant column or column name

Returns
Column

a string column representing the variant schema

Examples

>>> df = spark.createDataFrame([ {'json': '''{ "a" : 1 }'''} ])
>>> df.select(schema_of_variant(parse_json(df.json)).alias("r")).collect()
[Row(r='STRUCT<a: BIGINT>')]