Skip to content

[CALCITE-7801] SqlFunctions.cast: support BINARY, VARBINARY, GEOMETRY and UUID targets - #10

Merged
wasabii merged 1 commit into
calcite-7801-json-value-returning-conversionfrom
calcite-7801-cast-string-conversions
Sep 22, 2026
Merged

wasabii merged 1 commit into
calcite-7801-json-value-returning-conversionfrom
calcite-7801-cast-string-conversions

Conversation

@wasabii

@wasabii wasabii commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Extends SqlFunctions.cast — the runtime conversion JSON_VALUE/JSON_QUERY use — to the scalar target types a character value can convert to that it did not yet handle:

  • BINARY / VARBINARY — the value's bytes, zero-padded (BINARY) or truncated (VARBINARY) to the precision
  • GEOMETRY — parsed from EWKT
  • UUID

UUID and GEOMETRY use the same methods a generated CAST does. Binary has one caveat: a generated CAST encodes the string with the source type's charset, but cast receives a bare runtime value with no charset attached, so it uses the default charset (Util.getDefaultCharset()). For JSON_VALUE, whose extracted strings carry no SQL charset, that default is the correct source charset; for a source with an explicit non-default charset it would differ, which the runtime-value signature cannot express.

Adds SqlFunctionsCastTest.testCastFromStringToEachType (a character value → each scalar target type) plus JSON_VALUE ... RETURNING cases for uuid and varbinary.

Targeted at calcite-7801-json-value-returning-conversion so merging it updates upstream apache#5276.

Still unsupported, because they need structural type information a target descriptor cannot carry: ROW, MAP, INTERVAL, VARIANT.

… and UUID targets

Make the runtime cast used by JSON_VALUE feature-parallel with a generated
CAST for the remaining scalar types a character value can convert to: BINARY
and VARBINARY (encoding the value's bytes with the default charset, padding
or truncating to the precision), GEOMETRY (from EWKT), and UUID.

Add SqlFunctionsCastTest.testCastFromStringToEachType, which converts a
character value to each scalar target type, and JSON_VALUE RETURNING cases
for UUID and VARBINARY.
@wasabii
wasabii merged commit f31f12d into calcite-7801-json-value-returning-conversion Sep 22, 2026
10 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant