Pular para o conteúdo principal

schema_of_xml function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 14.1 and above

Returns the schema of an XML string in DDL format.

Syntax​

schema_of_xml(xmlStr [, options] )

Arguments​

  • xmlStr: A STRING expression with a XML string.
  • options: An optional MAP<STRING, STRING> literal.

Returns​

A STRING holding a definition of struct where the column names are derived from the XML element and attribute names. The field values hold the derived formatted SQL types.

For a complete list of options, see XML.

Examples​

SQL
> SELECT schema_of_xml('<p><a>1</a></p>');
STRUCT<a: BIGINT>

> SELECT schema_of_xml('<p><a attr="2">1</a><a>3</a></p>', map('excludeAttribute', 'true'));
STRUCT<a: ARRAY<BIGINT>>