pyspark.sql.functions.schema_of_variant#

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

Returns schema in the SQL format of a variant.

Added in version 4.0.0.

Parameters:
vColumn or str

a variant column or column name A column that evaluates to a variant.

Returns:
Column

a string column representing the variant schema Returns a column that evaluates to a string.

Examples

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