Skip to content

Native TRY_CAST: support STRING to BOOLEAN and temporal types #228

Description

@liuyongvs

Verified on PR #220 after rebasing onto merged #222: commit 16ebb1e5a45cc5420abf90473b785d6c0b908a82, released Apache Flink 2.2.1, JDK 17, default compatibility settings. Each probe uses independent stock-Flink and native-enabled environments with bounded runtime DataStream input. Successful comparisons check output values and resolved result types before classifying execution.

Suggested priority: P2. This is a verified native support gap; the successful probes return equal results through explicit Flink fallback.

STRING-to-integral and STRING-to-DECIMAL TRY_CAST controls are native, but BOOLEAN, DATE, TIME, TIMESTAMP and TIMESTAMP_LTZ results retain unsupported TRY_CAST gates. Valid, malformed and NULL strings were executed, with the temporal probes repeated in UTC, Asia/Shanghai and America/Los_Angeles.

Runtime probe

Input type:

ROW<`f0` STRING> NOT NULL

Input: [+I[true]]

SELECT TRY_CAST(f0 AS BOOLEAN) FROM src;

Flink result: [[true]]; resolved type: [BOOLEAN]. Native substitutions: 0.

Calc: unsupported TRY_CAST VARCHAR→BOOLEAN

Runtime probe

Input type:

ROW<`f0` STRING> NOT NULL

Input: [+I[2024-02-29 12:34:56.123]]

SELECT TRY_CAST(f0 AS TIMESTAMP_LTZ(3)) FROM src;

Flink result: [[2024-02-29T12:34:56.123Z]]; resolved type: [TIMESTAMP_LTZ(3)]. Native substitutions: 0.

Calc: unsupported TRY_CAST VARCHAR→TIMESTAMP_WITH_LOCAL_TIME_ZONE

Additional observed reasons: Calc: unsupported TRY_CAST VARCHAR->DATE, VARCHAR->TIME, and VARCHAR->TIMESTAMP (the logs use an arrow separator). Preserve malformed-input-to-NULL behavior, overflow/range limits and local-zone interpretation. Binary TRY_CAST is lower priority and should be tracked separately from these basic scalar types. Related completed narrower scope: #148.

Acceptance

Preserve released Flink values, resolved types, NULL behavior and relevant error/short-circuit semantics. Add runtime-source SQL regressions that assert the specific native operator as well as result parity; do not use constant folding as proof of native support. Keep safe fallback for unverified forms and update the corresponding operator coverage documentation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions