manner opened a new pull request, #29520:
URL: https://github.com/apache/flink/pull/29520
## What is the purpose of the change
This adds `XML_STRING(variant)` from FLIP-612, the inverse of `PARSE_XML`.
It writes a `VARIANT` as an XML string, so that `PARSE_XML(XML_STRING(v))`
gives `v` for any `v` from `PARSE_XML`.
Two points differ from the current FLIP text:
- Types are written with the `xs` prefix (`xsi:type="xs:int"`), and the root
element declares `xmlns:xs`. Without a prefix, `xsi:type="int"` resolves to the
default namespace, so a schema validator can't resolve the type. `PARSE_XML`
ignores the prefix of the type, so `int` and `xs:int` both keep working as
input.
- `BYTES` are written as `base64Binary`, and `PARSE_XML` reads
`base64Binary` back as `BYTES`.
## Brief change log
- `XML_STRING` in `BuiltInFunctionDefinitions`, `VariantToXmlWriter` and
`XmlStringFunction` in the runtime, `xmlString()` in the Table API, and
`xml_string` in Python.
- Mapping:
- `@` fields become attributes, the `$` field becomes text, and the other
fields become child elements, in the order of the `#` field.
- A `NULL` is written with `xsi:nil="true"`, and a typed scalar gets an
`xsi:type`.
- The root element declares `xsi` and `xs` if the document uses them and
doesn't declare them itself.
- A variant without an XML representation fails.
- The JDK `XMLStreamWriter` writes the tags and escapes the text. Names are
checked with the JDK DOM, which accepts exactly the names that the parser of
`PARSE_XML` accepts.
- `PARSE_XML` changes:
- `base64Binary` is parsed as `BYTES`. The text is checked against the XML
Schema grammar first, since the Java decoder accepts missing padding and unused
bits that aren't zero.
- `xmlns:xsi` and `xmlns:xs` with the XML Schema namespaces are dropped,
since `XML_STRING` declares them again. Declarations of these prefixes with
other namespaces are kept. Before, `xmlns:xsi` was always dropped.
- The keys and prefixes of the mapping are shared in `XmlVariantNames`.
- Docs for `XML_STRING` (en and zh), with a "VARIANT to XML" section next to
"XML to VARIANT".
## Verifying this change
This change added tests and can be verified as follows:
- `VariantToXmlWriterTest`: writing variants from `PARSE_XML`, round trips
with and without `force_array`, the lexical form of each type, and one case per
error.
- `XmlToVariantParserTest`: `base64Binary` and the declaration handling.
- `XmlFunctionsITCase`: SQL and Table API, a round trip, `NULL` input,
runtime and validation errors, and constant folding.
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changed class annotated with
`@Public(Evolving)`: yes, `BaseExpressions.xmlString()`
- The serializers: no
- The runtime per-record code paths (performance sensitive): yes, the new
function
- Anything that affects deployment or recovery: JobManager (and its
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? yes
- If yes, how is the feature documented? docs and JavaDocs
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Claude Opus 5.5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]