Repository navigation
Conversation
ccoltx
force-pushed
the
lexer/8-compare-with-official-lexer
branch
from
October 21, 2026 16:08
bbac3de to
6b41c38
Compare
This was referenced Oct 21, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
ccoltx
force-pushed
the
lexer/8-compare-with-official-lexer
branch
from
October 21, 2026 16:19
6b41c38 to
97dd3b6
Compare
This was referenced Oct 21, 2026
ccoltx
force-pushed
the
lexer/8-compare-with-official-lexer
branch
from
October 21, 2026 18:32
97dd3b6 to
8f50edf
Compare
Adds a shared corpus of tricky queries and checks the built-in, hand-written SQL handling against @clickhouse/lexer: - a unit test, with no server, that compares what each would send by the lexer's tokens, with an explicit list of known differences that fails when a difference appears or disappears; - an integration test where the server judges both modes against its answer for the original query. select.test.ts and the exec() trailing-semicolon tests now run with and without sql_lexer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ccoltx
force-pushed
the
lexer/8-compare-with-official-lexer
branch
from
October 21, 2026 18:43
8f50edf to
91967ab
Compare
kavirajk
pushed a commit
that referenced
this pull request
Oct 22, 2026
…rly (#1076) ## Summary Runs the ClickHouse Cloud integration tests after a PR is merged, or on request, instead of on every push to every PR. Also runs them one job at a time. This follows what [clickhouse-go](https://github.com/ClickHouse/clickhouse-go/blob/main/.github/workflows/run-tests-cloud.yml) does against the same Cloud service. ### Why The Cloud jobs use one ClickHouse Cloud service, which is shared with other client repositories (clickhouse-go uses the same `INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT_PROD` secret). On Cloud, every test file creates its own database, and `clean-up.yml` only drops databases older than 60 minutes. Each push to a PR started six Cloud jobs at once. Pushing a stack of eight PRs (#1065 to #1072) twice within 15 minutes filled the service: ``` Too many databases. The limit (max_database_num_to_throw) is set to 2800, the current number of databases is 2800. (code 725) ``` From then on, every Cloud job, including #1075's, failed during setup before running any tests. This likely affects the other repositories that use the same service too. ### What - **New `tests-cloud.yml`** with the Node.js and Web Cloud jobs, which are removed from `tests-node.yml` and `tests-web.yml`. It runs: - after a merge (push to `main` or `release`, with the same path filters as before), on the daily schedule, and on `workflow_dispatch`; - on a PR only when a maintainer adds the **`tests:run-cloud`** label. A final job removes the label, so adding it again runs the tests again. - **One Cloud job at a time across the repository:** - one workflow-level concurrency group, `tests-cloud`, with `cancel-in-progress: false`, so a whole run holds the lock and other runs wait. Of the waiting runs, only the newest is kept. - within a run, `max-parallel: 1` runs the matrix jobs one by one, and the Web jobs wait for the Node.js jobs. - runs whose jobs will be skipped, for example a PR that got a different label, get a group of their own (`tests-cloud-skipped-<run id>`), so they can't replace a waiting Cloud run. - **`examples.yml` passes the Cloud credentials only after a merge and on manual runs.** On PRs they're empty, so the `create_table_cloud` example (Node.js and Web) skips itself, which it already did when the credentials were missing. Before this, each of the 4 examples jobs of every PR hit the Cloud service. With the lexer stack's PRs running at once, that example timed out in 28 jobs. - **`clean-up.yml` runs hourly instead of on every push.** It used to run on every push to every branch, and a new push cancelled one still in progress. Dropping databases one by one takes a while, so a burst of pushes kept restarting it. It now runs at :17 every hour, which also puts a run before the 09:00 scheduled Cloud tests, and on demand (`workflow_dispatch`). Only one runs at a time, and a running cleanup is never cancelled. - **Fork and Dependabot PRs are still skipped**, as before, because Cloud secrets aren't available to them. It uses `pull_request`, not `pull_request_target`, so a PR's code never runs with secrets unless it comes from a branch in this repository. - **`npm ci` instead of `npm install`** in the new workflow, so dependencies are installed exactly as locked, verified by hash. This resolves the Scorecard Pinned-Dependencies alerts on these two steps. The other workflows still use `npm install`, so their existing alerts are unchanged. - **`codecov.yml`:** `after_n_builds` goes from 7 to 5, the uploads every PR gets. With 7, Codecov never posted a status on fork PRs (for example #1041 and #1024), which skip the Cloud jobs, and with this change it wouldn't post on most PRs. The cloud flags are carried forward (`carryforward: true` was already set). ### Trade-offs - **Cloud regressions show up after merge** (on `main`), unless the label is added before merging. - **A Cloud run takes longer** with jobs one at a time: 4 Node.js versions and then 2 browsers, about 25–30 minutes instead of about 5. - **The `tests:run-cloud` label is new.** I've created it in the repository. ## Testing - All workflow and Codecov YAML parses, and Prettier passes. `actionlint` wasn't available locally. - The new workflow can only really be checked on GitHub: after merge (push to `main`), and by adding `tests:run-cloud` to a PR once the Cloud service has been cleaned up. ## Checklist - [x] CI only; no changelog entry needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
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.
Tracking issue: #1074. Stack: #1065 → #1066 → #1067 → #1068 → #1069 → #1070 → #1071 → #1072
Part 8 of the lexer stack. Depends on #1071. Tests only, no behavior change.
Why
The client's built-in SQL handling is hand-written, and every fix to it (#1031, #972, …) risks missing a rule of ClickHouse's real lexer. This PR turns
@clickhouse/lexerinto a reference for that code, so a change to the built-in handling gets immediate feedback in the unit suite, without a server.What
__tests__/utils/sql_corpus.ts:sqlCorpus: about 50 queries that are easy to get wrong by hand. They cover semicolons before every comment style (including//,#!and\r), semicolons in strings, quoted identifiers and heredocs, nested comments,$in identifiers, and trailingSETTINGSclauses.sqlLexerModes: the two modes, fordescribe.each.KNOWN_DIFFERENCES: where the built-in handling reads a corpus query differently from the lexer, per method, each with a reason (query(): trailing semicolon followed by a comment breaks FORMAT append (SYNTAX_ERROR 62) #973, [backfill: ClickHouse/clickhouse-js] client.query() unconditionally appends FORMAT after user SETTINGS clause, producing invalid SQL on older ClickHouse servers #970, or spaced semicolons).New
unit/sql_rewriting_vs_lexer.test.ts(no server): for every corpus query, compares whatquery()andcommand()/exec()would send, in each mode.integration/sql_lexer.test.ts: the same corpus, judged by the server.exec()withdefault_format, so no FORMAT clause is appended to it.Existing tests now run in both modes:
select.test.ts(16 tests per mode);node_exec.test.tsandweb_exec.test.ts.Tests that check exact SQL on the default path (tracing, query log) are unchanged.
What the feedback looks like
To check it, I temporarily swapped PR #1031's scanner into
sql/legacy.ts. The unit test then:SELECT 1; // noteandSELECT 1 AS a$t$; -- $t$) as known differences;Testing
... UNION ALL SELECT 2returns rows in no fixed order. The corpus now uses identical rows.🤖 Generated with Claude Code