Add pushdown for JSONB ? operator, with casting - #344
Open
theory wants to merge 1 commit into
Open
Conversation
serprex
reviewed
Aug 8, 2026
serprex
reviewed
Aug 8, 2026
serprex
reviewed
Aug 8, 2026
Comment on lines
+102
to
+107
| ORDER BY id; | ||
| id | ||
| ---- | ||
| 1 | ||
| 2 | ||
| (2 rows) |
Member
There was a problem hiding this comment.
on postgres this would include "key" (6)
Collaborator
Author
There was a problem hiding this comment.
david=# select '{"key": 1}'::jsonb ? '"key"';
?column?
----------
f
serprex
reviewed
Aug 8, 2026
| deparseJsonbNonnullDocument(document, document_kind, context); | ||
| appendStringInfoString( | ||
| buf, | ||
| ") = 'Array', arrayExists(jsonb_exists_element -> " |
Member
There was a problem hiding this comment.
This will cause trouble if they have column named jsonb_exists_element
Collaborator
Author
There was a problem hiding this comment.
I actually prefer x, but maybe it should be __x.
Collaborator
Author
There was a problem hiding this comment.
Renamed to elem and added a column named elem to the tests that doesn't conflict AFAICT.
Member
There was a problem hiding this comment.
conflict is when you're doing col1 ? elem
theory
force-pushed
the
k-bx-agent/jsonb-exists-pushdown
branch
2 times, most recently
from
August 8, 2026 05:53
e9d1116 to
55f1436
Compare
Added pushdown for the JSONB `?` existence operator. Evaluates not only ClickHouse JSON columns mapped to JSONB, but also ClickHouse String columns that contain JSON, thus working on both JSON objects and JSON arrays. This requires a bit of complicated ClickHouse function dispatch, but does the trick. Test output varies on ClickHouse 24.3 and earlier because the "JSON" feature at that time required the same keys in every object in the column, so the tests do in fact find the key in every row. Signed-off-by: David E. Wheeler <david.wheeler@clickhouse.com>
theory
force-pushed
the
k-bx-agent/jsonb-exists-pushdown
branch
from
August 8, 2026 05:54
55f1436 to
f85f98a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added pushdown for the JSONB
?existence operator. Evaluates not only ClickHouse JSON columns mapped to JSONB, but also ClickHouse String columns that contain JSON, thus working on both JSON objects and JSON arrays. This requires a bit of complicated ClickHouse function dispatch, but does the trick.Test output varies on ClickHouse 24.3 and earlier because the "JSON" feature at that time required the same keys in every object in the column, so the tests do in fact find the key in every row.
Resolves #325