Hi Moritz,

this is an excellent design document with the right level of detail. I really like the design, it is a nice mixture of concerns. The result of PARSE_XML looks and feels like a VARIANT while the XML content is preserved in a lossless fashion and all attributes and text is accessible. It is a nice combination of what other vendors offer (modulo the historical legacy they have to deal with).

Looking at various UDF implementations, XML handling is by far the most important reason for the need of a custom function. So +1 for this FLIP.

Thanks,
Timo

On 11.09.26 14:54, Moritz Manner wrote:
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