ClickHouse: Support unparenthesized IN right-hand side#2385
Open
dinmukhamedm wants to merge 1 commit into
Open
ClickHouse: Support unparenthesized IN right-hand side#2385dinmukhamedm wants to merge 1 commit into
dinmukhamedm wants to merge 1 commit into
Conversation
iffyio
reviewed
Jun 20, 2026
Comment on lines
+4395
to
+4396
| // ClickHouse accepts a bare expression as the IN RHS (e.g. `x IN 'a'` or | ||
| // a `{name:Type}` placeholder), wrapping it into a single-element list. |
Contributor
There was a problem hiding this comment.
Suggested change
| // ClickHouse accepts a bare expression as the IN RHS (e.g. `x IN 'a'` or | |
| // a `{name:Type}` placeholder), wrapping it into a single-element list. |
| #[test] | ||
| fn parse_in_unparenthesized_placeholder() { | ||
| // ClickHouse `{name:Type}` query-parameter placeholder as the IN RHS, without parens. | ||
| match clickhouse().expr_parses_to("x IN {ids:Array(UInt64)}", "x IN ({ids: Array(UInt64)})") { |
Contributor
There was a problem hiding this comment.
lets rewrite these tests to use all_dialects_where and verified_stmt, we can remove the test for dialects that donts support the feature
Comment on lines
+1853
to
+1858
| Expr::InList { list, negated, .. } => { | ||
| assert!(!negated); | ||
| assert_eq!(list.len(), 1); | ||
| assert!(matches!(list[0], Expr::Dictionary(_))); | ||
| } | ||
| other => panic!("expected InList, got {other:?}"), |
Contributor
There was a problem hiding this comment.
we can probably drop the ast assertions, I think the funcationality is simple enough to rely only on roundtrip tests
Comment on lines
+439
to
+442
| /// side of `IN`, without a parenthesized list — as in `x IN 'a'` or the | ||
| /// ClickHouse `{name:Type}` query-parameter placeholder `x IN {ids:Array(UInt64)}`. | ||
| /// The expression is wrapped into a single-element list, matching ClickHouse, | ||
| /// which reformats `x IN 'a'` to `x IN ('a')`. |
Contributor
There was a problem hiding this comment.
Suggested change
| /// side of `IN`, without a parenthesized list — as in `x IN 'a'` or the | |
| /// ClickHouse `{name:Type}` query-parameter placeholder `x IN {ids:Array(UInt64)}`. | |
| /// The expression is wrapped into a single-element list, matching ClickHouse, | |
| /// which reformats `x IN 'a'` to `x IN ('a')`. | |
| /// side of `IN`, without a parenthesized list — as in `x IN 'a'`. |
| true | ||
| } | ||
|
|
||
| fn supports_in_unparenthesized_expr(&self) -> bool { |
Contributor
There was a problem hiding this comment.
lets add a link to the docs where the syntax comes from
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.
Fixes #2384
Note: The fix is a little broader than just the parameterized ClickHouse queries, e.g.
WHERE id IN {ids: Array(UUID)}.After opening the issue, I experimented a little more with ClickHouse, and found that it wraps in parenthesis anything on the RHS of
IN, even for singular values, e.g.