schema_of_csv function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns the schema of a CSV string in DDL format.


schema_of_csv(csv [, options] )


  • csv: A STRING literal with valid CSV data.

  • options: An optional MAP literals where keys and values are STRING.


A STRING composing a struct. The field names are derived by position as _Cn. The values hold the derived formatted SQL types. For details on options see from_csv function.


> DESCRIBE SELECT schema_of_csv('1,abc');
 STRUCT<`_c0`: INT, `_c1`: STRING>