-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29317: Iceberg: get_variant() wrongly return null for invalid entries #6185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
| @@ -0,0 +1 @@ | |||
| SELECT variant_get(parse_json('{"a": 1}'), '$[0]'); No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't it better to do this in itest?
|
not sure about this, similar change in variant_get(parse_json('{"a": 1}'), '$[0]') ✔ Expected result NULL (not an error) — because the path '$[0]' does not exist in the JSON structure. This is consistent with typical JSON-path behavior: there is a difference between the path that is valid, but matches nothing and invalid syntax |
|
in our case: |
I imagined it the following way: ✅ variant_get Throws an error if the extraction fails Errors happen when:
If the path is valid but does not match anything, Iceberg returns NULL (same as normal JSONPath behavior) ✔️ Safe for normal use ✅ try_variant_get Never throws an error If anything goes wrong, it returns NULL It swallows:
✔️ Safe for messy/unknown data |
|
I am confused. Isn't this what we fix here: variant_get was returning |
variant_get(parse_json('{"a": 1}'), '$[0]') should return NULL, not error. I've added examples, please take a look |
|
ohhk, you mean to say the current behaviour is correct, we need not to changed anything? |
it's probably correct for the empty path case, but not for the rest of scenarios (JSONPath is invalid, unsupported type cast, etc) where we return NULL. |



What changes were proposed in this pull request?
For invalid entries get_variant() doesn't return null
Why are the changes needed?
To correct the behaviour of to_variant()
Does this PR introduce any user-facing change?
Yes, get_variant() throws instead of returning null
How was this patch tested?
UT