Hey everyone,

I'd like to start a discussion on FLIP-612: Native XML Functions for Flink
SQL [1].

The goal is native XML parsing in Flink SQL, parsing XML into a VARIANT
instead of requiring custom UDFs.

The FLIP proposes three functions. PARSE_XML and TRY_PARSE_XML turn an XML
string into a VARIANT, and XML_STRING turns a VARIANT back into an XML
string.
This mirrors the existing JSON functions PARSE_JSON, TRY_PARSE_JSON, and
JSON_STRING.

Once XML is a VARIANT, you query it the same way as the output of PARSE_JSON:
with the variant accessors (variant.key, variant['key'], variant[index])
and a CAST to the type you need.

The main part is the XML→VARIANT mapping: attributes and text go into @/$
fields, and since Variant objects store fields sorted by key rather than in
document order, a # field is used to recover the original order between
differently-named siblings. Details and examples are in the FLIP.

It's a small, additive API, no new SQL grammar or Table API methods needed.

Looking forward to your thoughts!

Best,
Moritz

[1]
https://cwiki.apache.org/confluence/spaces/FLINK/pages/451974259/FLIP-612+Native+XML+Functions+for+Flink+SQL

Reply via email to