-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
cast(json_parse(x) as map(varchar, json)) doesnt canonicalize the map json. #24207
Comments
Although JSON objects inherently have no concept of sort order, within the Java eval ensuring the keys are sorted is important because they're stored simply as strings, so the sorting is necessary for ordering, hashing, etc.
|
It does simplify the code and makes it more performant ; canonicalization makes it possible for us to treat the underlying json as a varchar and thus simplifies group by's and comparisons. |
The map function will not sort a json object by its keys, despite the json_parse function sorting the same input. If implemented, this will sort json objects. Resolves prestodb#24207
The map function will not sort a json object by its keys, despite the json_parse function sorting the same input. If implemented, this will sort json objects. Resolves prestodb#24207
The map function will not sort a json object by its keys, despite the json_parse function sorting the same input. If implemented, this will sort json objects. Resolves prestodb#24207
The map function will not sort a json object by its keys, despite the json_parse function sorting the same input. If implemented, this will sort json objects. Resolves prestodb#24207
The map function will not sort a json object by its keys, despite the json_parse function sorting the same input. If implemented, this will sort json objects. Resolves prestodb#24207
The map function will not sort a json object by its keys, despite the json_parse function sorting the same input. If implemented, this will sort json objects. Resolves prestodb#24207
The map function will not sort a json object by its keys, despite the json_parse function sorting the same input. If implemented, this will sort json objects. Resolves prestodb#24207
The map function will not sort a json object by its keys, despite the json_parse function sorting the same input. If implemented, this will sort json objects. Resolves prestodb#24207
Description
Consider the below query :
Whereas:
The problem here is that the inner json string {"rn"...} is not sorted. This causes inconsistencies with Prestissimo where it is sorted. Secondly json_parse without the cast canonicalizes the json and has the inner json sorted; so CAST not sorting the inner json seems like a miss. This can cause inconsistencies if we group by json and the json is taken from a cast.
Environment
Expected Behavior
Cast should also canonicalize the inner json.
Current Behavior
See description.
Possible Solution
Sort/Canonicalize the inner json.
Context
This causes inconsistencies with Prestissimo/Velox and results in verification noise.
The text was updated successfully, but these errors were encountered: