Skip to content

ClickHouse: Support GLOBAL IN / GLOBAL NOT IN - #2598

Open
s5dsn-eqee wants to merge 4 commits into
apache:mainfrom
s5dsn-eqee:clickhouse-global-in
Open

s5dsn-eqee wants to merge 4 commits into
apache:mainfrom
s5dsn-eqee:clickhouse-global-in

Conversation

@s5dsn-eqee

Copy link
Copy Markdown
Contributor

Closes: #2597

Dialects: ClickHouse

@codecov-commenter

codecov-commenter commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.15%. Comparing base (14cbf75) to head (70c5966).

Files with missing lines Patch % Lines
src/parser/mod.rs 93.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2598      +/-   ##
==========================================
+ Coverage   81.14%   81.15%   +0.01%     
==========================================
  Files          42       42              
  Lines       33736    33762      +26     
  Branches    33736    33762      +26     
==========================================
+ Hits        27376    27401      +25     
  Misses       2797     2797              
- Partials     3563     3564       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94 LucaCappelletti94 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will review later today, but please in the meantime add a couple of examples for the fuzzer corpus.

@LucaCappelletti94 LucaCappelletti94 added the waiting on reviewer PR needs to be reviewed label Oct 1, 2026
Comment thread src/parser/mod.rs Outdated
@@ -4468,6 +4478,7 @@ impl<'a> Parser<'a> {
expr: Box::new(expr),
list: vec![self.parse_expr()?],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClickHouse groups x GLOBAL IN t2 AND y = 2 as (x GLOBAL IN t2) AND y = 2, but this path renders x GLOBAL IN (t2 AND y = 2).

Suggested change
list: vec![self.parse_expr()?],
list: vec![self.parse_subexpr(self.dialect.prec_value(Precedence::Eq))?],

.parse_sql_statements("SELECT * FROM t WHERE x GLOBAL IN (1)")
.is_err());
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some red tests

Suggested change
}
}
#[test]
fn global_in_bare_table_binds_before_and() {
let expr =
clickhouse().expr_parses_to("x GLOBAL IN t2 AND y = 2", "x GLOBAL IN (t2) AND y = 2");
assert!(matches!(
expr,
BinaryOp {
left,
op: BinaryOperator::And,
..
} if matches!(*left, Expr::InList { global: true, .. })
));
}
#[test]
fn global_in_bare_table_binds_before_equality() {
let expr = clickhouse().expr_parses_to("x GLOBAL IN t2 = 1", "x GLOBAL IN (t2) = 1");
assert!(matches!(
expr,
BinaryOp {
left,
op: BinaryOperator::Eq,
..
} if matches!(*left, Expr::InList { global: true, .. })
));
}

@LucaCappelletti94 LucaCappelletti94 added waiting on contributor The review needs further refinements by its author and removed waiting on reviewer PR needs to be reviewed labels Oct 3, 2026
@LucaCappelletti94 LucaCappelletti94 added waiting on reviewer PR needs to be reviewed and removed waiting on contributor The review needs further refinements by its author labels Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ClickHouse waiting on reviewer PR needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClickHouse: Support GLOBAL IN / GLOBAL NOT IN

3 participants