Skip to content

1.23 beta3 - #890

Merged
peter-leonov-ch merged 2 commits into
releasefrom
main
Jun 25, 2026
Merged

1.23 beta3#890
peter-leonov-ch merged 2 commits into
releasefrom
main

Conversation

@peter-leonov-ch

Copy link
Copy Markdown
Collaborator

Summary

A short description of the changes with a link to an open issue.

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

peter-leonov-ch and others added 2 commits June 24, 2026 19:53
## 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>
Copilot AI review requested due to automatic review settings June 25, 2026 08:45
@github-advanced-security

Copy link
Copy Markdown

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:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@peter-leonov-ch
peter-leonov-ch merged commit fae5998 into release Jun 25, 2026
225 of 227 checks passed
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.

3 participants