Skip to content

ClickHouse: support the strictness before the join type (ASOF LEFT JOIN, ANY LEFT JOIN, ...) - #987

Closed
MunMunMiao wants to merge 1 commit into
sql-formatter-org:masterfrom
MunMunMiao:clickhouse-join-strictness-first
Closed

MunMunMiao wants to merge 1 commit into
sql-formatter-org:masterfrom
MunMunMiao:clickhouse-join-strictness-first

Conversation

@MunMunMiao

@MunMunMiao MunMunMiao commented Oct 14, 2026 •

Copy link
Copy Markdown

Problem

The ClickHouse dialect only knows the join strictness after the join type (LEFT ASOF JOIN, LEFT ANY JOIN). ClickHouse also accepts it before the join type, and its documentation uses that form:

  • ASOF LEFT JOIN in the syntax of the ASOF JOIN section
  • ANY LEFT JOIN in an example query on the same page
  • ALL INNER JOIN in the text about the block nested loop join

Such a join is not recognised as one unit, so the strictness keyword is left at the end of the previous line:

SELECT a FROM t1 ASOF LEFT JOIN t2 ON t1.k = t2.k AND t1.t >= t2.t ANY LEFT JOIN t3 USING (k)

Before (15.9.0, language: 'clickhouse'):

SELECT
  a
FROM
  t1 ASOF
  LEFT JOIN t2 ON t1.k = t2.k
  AND t1.t >= t2.t ANY
  LEFT JOIN t3 USING (k)

After:

SELECT
  a
FROM
  t1
  ASOF LEFT JOIN t2 ON t1.k = t2.k
  AND t1.t >= t2.t
  ANY LEFT JOIN t3 USING (k)

Change

Adds [GLOBAL] {ANY|ALL|ASOF} [INNER|LEFT|RIGHT|FULL] [OUTER] JOIN next to the existing join phrase. The existing forms are unchanged. I only included the strictness words that the documentation shows before the join type (ANY, ALL, ASOF).

Tests

Added the new forms to the supportsJoin list in test/clickhouse.test.ts (ANY LEFT JOIN, ALL INNER JOIN, ASOF LEFT JOIN, ASOF LEFT OUTER JOIN, GLOBAL ANY LEFT JOIN, ...). pnpm exec jest passes for all dialects (5901 passed, 1 skipped), and tsc --noEmit, prettier --check and eslint are clean.

Fixes #989.


This change was prepared with Claude Code (an AI coding assistant) and checked by running the full test suite locally.

The ClickHouse dialect only recognised the strictness after the join
type (`LEFT ASOF JOIN`). ClickHouse also accepts it before the type, and
its documentation uses that form (`ASOF LEFT JOIN`, `ANY LEFT JOIN`,
`ALL INNER JOIN`). Without it, `ASOF` and `ANY` stayed at the end of the
previous line and the join was split in two.
Copilot AI balanced review requested due to automatic review settings October 14, 2026 03:58

Copilot AI 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.

🟢 Approval recommended

The phrase expansion correctly covers the intended syntax and is supported by focused formatting tests.

0 open findings

What changed in this PR

Adds ClickHouse formatting support for join strictness keywords placed before the join type.

Changes:

  • Recognizes ANY, ALL, and ASOF before join types, optionally with GLOBAL and OUTER.
  • Adds formatting tests for representative strictness-first joins.
File Description
src/​languages/​clickhouse/​clickhouse.formatter.ts Adds strictness-first join phrases.
test/​clickhouse.test.ts Tests supported strictness-first forms.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@MunMunMiao

Copy link
Copy Markdown
Author

Closing for now: I'm going to handle the formatting on my side instead. Thanks for the library.

@MunMunMiao MunMunMiao closed this Oct 14, 2026
@MunMunMiao
MunMunMiao deleted the clickhouse-join-strictness-first branch October 14, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FORMATTING] ClickHouse: ASOF LEFT JOIN and ANY LEFT JOIN are split into two lines

2 participants