Share via


to_xml 函式

適用於:check marked yes Databricks SQL check marked yes Databricks Runtime

傳回 XML 字串,其中包含 中指定的 expr結構。

語法

to_xml(expr [, options] )

引數

  • expr:STRUCT 表達式。
  • options:選擇性的 MAP 常值運算式,其索引鍵和值為 STRING。

傳回

字串。

如需可能options的詳細數據,請參閱 from_xml 函式。

範例

> SELECT to_xml(named_struct('a', 1, 'b', 2));
 <ROW><a>1</a><b>2</b></ROW>
> SELECT to_xml(named_struct('time', to_timestamp('2015-08-26', 'yyyy-MM-dd')), map('timestampFormat', 'dd/MM/yyyy'));
 <ROW><time>26/08/2015</time></ROW>