Skip to content

[Variant] Support safe cast option for json_to_variant #11775

Open

Description

@sdf-jkl

Is your feature request related to a problem or challenge?

json_to_variant fails the entire batch when a row contains invalid JSON. Implementing try_parse_json downstream requires returning SQL NULL for that row while preserving valid rows.

Describe the solution you'd like

Add a required CastOptions argument to json_to_variant, following the error policy used by variant_get:

  • safe: true: return SQL NULL for rows that fail to parse.
  • safe: false: return an error.

Callers can pass safe: false for strict parsing or safe: true for try parsing. Preserve input SQL NULLs and keep JSON null as a Variant null. Unsupported input types should still return an error.

Activity

  1. added
    enhancement
    on Oct 21, 2026
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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions