Skip to content

variant_get should follow JSONpath semantics #9606

Description

@scovich

From @scovich in #8354 (comment):

there's still an open question of whether we intend to follow the jsonpath spec in our path step logic, as e.g. spark does? #8354 (comment)

The jsonpath spec requires foo[100] to return NULL if foo is not an array, and also requires returning NULL if foo has fewer than 101 elements. Similarly, foo.bar should return NULL if foo is not a struct and should also return NULL if foo has no field named bar. Safe casting would only influence actual casting decisions, e.g. a variant_get call that specifically requests a string and the requested path points to a struct.

In contrast, our current struct handling code currently returns an error if safe casting is disabled and:

  • a Field path step encounters a "wrong" type (L169)
  • an Index path step encounters a "wrong" type (L224)
  • an Index path step is out of bounds (L99)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions