Support equal comparison for JSON column#72991
Conversation
|
This is an automated comment for commit 39d687f with description of existing statuses. It's updated for the latest CI running ✅ Click here to open a full report in a separate page Successful checks
|
tests/queries/0_stateless/03282_json_equal_comparison.reference
Outdated
Show resolved
Hide resolved
| {"json1" : {"a" : 42, "b" : 42, "c" : 42, "d" : 42, "e" : 42}, "json2" : {"a" : 42, "b" : 42, "d" : 42, "c" : 42, "e" : "42"}} | ||
| {"json1" : {"a" : 42, "b" : 42, "c" : 42, "d" : 42, "e" : 42}, "json2" : {"a" : 42, "b" : 42, "d" : 42, "c" : 42, "e" : 42.0}}; | ||
|
|
||
| select json1, json2, json1 == json2 from test; |
There was a problem hiding this comment.
Also it's worth adding cases with other operators (expecting error or whatever)
There was a problem hiding this comment.
Can we compare for inequality?
Yes, I will add tests for it as well.
There was a problem hiding this comment.
Added test for inequality.
Also it's worth adding cases with other operators (expecting error or whatever)
I will make a separate PR with tests when I add an error for other operators as a backward incompatible change under a setting
| void updatePermutation(PermutationSortDirection, PermutationSortStability, size_t, int, Permutation &, EqualRanges &) const override {} | ||
|
|
||
| /// Values of ColumnObject are not comparable. | ||
| /// Values of ColumnObject are not comparable for less and greater functions. |
There was a problem hiding this comment.
Do we force it somewhere, so other operators shows proper error?
There was a problem hiding this comment.
Unfortunately no, for not comparable types like JSON/Object/AggregateFunction/SimpleAggregateFunction we just fallback to generic implementation of less/greater/etc functions that uses IColumn::compareAt (and for these types it always returns 0 except JSON now that returns 0 for equal and 1 for all other cases).
I would change it and throw an exception in functions less/greater/etc if type is not comparable. And maybe in ORDER BY as well. But it will be backward incompatible change, so let me do it in a separate PR under a setting.
|
Is |
No, it was a mistake. Changed it to just |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Support equal comparison for values of JSON column.
Documentation entry for user-facing changes
CI Settings (Only check the boxes if you know what you are doing):