You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
variant_get should follow JSONpath semantics #9606
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)
A syntactically valid segment MUST NOT produce errors when executing the query. This means that some operations that might be considered erroneous, such as using an index lying outside the range of an array, simply result in fewer nodes being selected.
Here, "syntactically valid" is referring to the previous section (2.1):
A JSONPath implementation MUST raise an error for any query that is not well-formed and valid. The well-formedness and the validity of JSONPath queries are independent of the JSON value the query is applied to. No further errors relating to the well-formedness and the validity of a JSONPath query can be raised during application of the query to a value. This clearly separates well-formedness/validity errors in the query from mismatches that may actually stem from flaws in the data.
Note: Integer overflow in an index is well-formed but not valid, so it's allowed to produce an error.
Activity
scovich commentedon Mar 23, 2026
I think spark is just implementing jsonpath semantics:
Here, "syntactically valid" is referring to the previous section (2.1):
Note: Integer overflow in an index is well-formed but not valid, so it's allowed to produce an error.
Originally posted by @scovich in #8354 (comment)
scovich commentedon Mar 23, 2026
Also from @alamb in #8354 (comment):
[-]variang_get should follow JSONpath semantics[/-][+]variant_get should follow JSONpath semantics[/+][Variant] `variant_get` should follow JSONPath semantics for Field pa…
alamb commentedon Apr 23, 2026
label_issue.pyautomatically added labels {'parquet-variant'} from #9599[Variant] `variant_get` should follow JSONPath semantics for Field pa…