raminqaf opened a new pull request, #29807:
URL: https://github.com/apache/flink/pull/29807
## What is the purpose of the change
Backport of #29804 to release-2.4. Casts from `VARIANT` are new in 2.4.
Without these commits, 2.4.0 ships a cast that can't turn a JSON string into
bytes, and `BOOLEAN`, binary and malformed-variant failures that escape as
`VariantTypeException` instead of `TableRuntimeException`:
| Query | release-2.4 today
| With these commits
|
|-----------------------------------------|--------------------------------------------------------------|-----------------------------------------------------------------------------|
| `CAST(PARSE_JSON('"abc"') AS BYTES)` | `VariantTypeException: Expected
type BYTES but got STRING` | `x'616263'`
|
| `CAST(PARSE_JSON('true') AS BYTES)` | `VariantTypeException: Expected
type BYTES but got BOOLEAN` | `TableRuntimeException: Cannot cast a VARIANT
BOOLEAN value to BYTES. ...` |
| `CAST(PARSE_JSON('"true"') AS BOOLEAN)` | `VariantTypeException: Expected
type BOOLEAN but got STRING` | `TableRuntimeException: Cannot cast a VARIANT
STRING value to BOOLEAN. ...` |
## Brief change log
- Cherry-pick of 7c5b2379cb5 (FLINK-40319), applied without conflicts
- Cherry-pick of de2cb88cb0c (FLINK-41301). release-2.4 has no
`VARIANT_GET`, so the changes to `VariantGetFunction` and
`VariantFunctionsITCase` are left out. The rest applied without conflicts.
## Verifying this change
`FromVariantConverterTest`, `VariantCastUtilsTest`,
`ToVariantConverterTest`, `CastRulesTest`, `CastFunctionITCase`,
`CastFunctionMiscITCase` and `VariantSemanticTest` pass on this branch.
## 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)`: no
- The serializers: no
- The runtime per-record code paths (performance sensitive): yes. A cast
from `VARIANT` to a binary or `BOOLEAN` target checks the kind once per value,
which the strict getters already did.
- 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, a cast from a
`VARIANT` string to `BINARY` and `VARBINARY`
- If yes, how is the feature documented? docs
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes (please specify the tool below)
Generated-by: Claude Code 2.1.319 (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]