1.23 beta3 - #890
Merged
Merged
Conversation
## What
Adds a small, self-contained ClickHouse **data-type string** parser
under `type-parser/` — the kind of string sent in the types row of
`RowBinaryWithNamesAndTypes` (e.g. `Array(Nullable(UInt64))`, `Tuple(a
UInt8, b String)`, `Enum8('a' = 1)`, `Decimal(10, 2)`) — parsed into a
JSON AST that mirrors the server's `EXPLAIN AST json = 1` data-type
subtree (format v2).
Two implementations:
- **`mini-parser-extracted/`** — the C++ library, extracted from the
server's `ParserDataType` (`src/Parsers/ParserDataType.cpp`) but with
**no dependency on the ClickHouse source tree** (only the C++20 stdlib).
A purpose-built tokenizer replaces the full `Lexer`; plain structs
replace `IAST`/`Field`.
- **`mini-parser-ts/`** — a faithful **TypeScript port**,
module-for-module (`ast` / `lexer` / `parser` / `json`), preserving the
original control flow, branch ordering, and `pos` save/restore points.
No runtime dependencies.
## Coverage
Scalars, parametric types with literal args (`Decimal`, `FixedString`,
`DateTime64`, …), nested type args (`Array`, `Map`, `Nullable`,
`LowCardinality`, `Variant`, …), enums (explicit → `EnumDataType`;
auto-assigned → generic `DataType`), named/unnamed/mixed tuples,
`Nested`, `Dynamic(max_types = N)`, legacy `Object('json')`, and the
SQL-standard multi-word aliases (`DOUBLE PRECISION`, `CHAR VARYING`,
`INT SIGNED`, …).
Deliberately deferred (parser returns a clear error):
`AggregateFunction` / `SimpleAggregateFunction`, and the new `JSON(...)`
object-argument syntax.
## Verification
- **C++**: `ctest` — oracle (50/50) + unsupported (2/2) pass.
- **TypeScript**: strict `tsc` clean; `node:test` unit suite (12/12);
unsupported (5/5); oracle vs. the real server (50/50).
- **Cross-check**: the TS output is **byte-identical** to the C++
`chdt-parse` across the full corpus (50 supported + 5 unsupported +
edge/error cases) — identical stdout, stderr messages, byte offsets, and
exit codes.
The oracle suites compare against a `clickhouse` binary built from
peter-leonov-ch/ClickHouse#1 — the AST-format
changes this parser mirrors live in that PR, so a stock server build
will not match.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
) ## Summary `ClickHouseSettings` includes `SettingsMap` (a class with a `private` member) in its index signature, so TypeScript compares it **nominally**. Since `@clickhouse/client` and `@clickhouse/client-web` each bundle their own copy of the common module, their `ClickHouseSettings` types are **mutually unassignable**. Consumers that share a single settings-producing helper across both the Node.js and Web clients therefore cannot type it against a single concrete `ClickHouseSettings`. This adds **`ClickHouseSettingsInterface`** — identical to `ClickHouseSettings` but with `SettingsMap` omitted from the index-signature value union (the only nominal member). It is structurally identical across all three packages and assignable *into* each package's `ClickHouseSettings`, so a shared helper can return it and have it flow into both the node and web `client.query({ clickhouse_settings })` calls **without casts**. Re-exported from `client-common`, `client-node`, and `client-web`. ## Why A real consumer (HyperDX) has one shared `processClickhouseSettings()` that feeds both the node and web clients. After the client packages began bundling their own copy of common, the node and web `ClickHouseSettings` diverged nominally, breaking `tsc` (`TS2322`) and tripping `@typescript-eslint/no-unsafe-type-assertion` on the existing casts. A package-neutral settings type lets such consumers depend only on `@clickhouse/client` / `@clickhouse/client-web` and drop their `@clickhouse/client-common` dependency. ## Caveat Values typed as `SettingsMap` cannot be carried through `ClickHouseSettingsInterface` — use `ClickHouseSettings` if you need them. No named setting field is typed as `SettingsMap`; it is reachable only via the catch-all index signature. ## Test plan - [x] `tsc --noEmit` passes for `client-common`, `client-node`, and `client-web` --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
A short description of the changes with a link to an open issue.
Checklist
Delete items not relevant to your PR: