239 Commits
Author SHA1 Message Date
Pedro Ferreira 518930057a Oracle fix for SummingMergeTree 2026-10-22 16:52:18 +00:00
Pedro Ferreira 5a874a1f66 Merge error codes and reduce branches 2026-10-06 14:16:12 +00:00
Pedro Ferreira df55350174 Merge remote-tracking branch 'origin/master' into fix-ast-fuzzer-error 2026-10-04 20:33:53 +00:00
Pedro Ferreira a81b9fd2d0 Don't label query oracle mismatches as errors 2026-10-02 15:38:33 +00:00
Konstantin Bogdanov 1f4d465b28 Merge remote-tracking branch 'origin/master' into HEAD
# Conflicts:
#	src/Client/BuzzHouse/Generator/StatementGenerator.cpp
#	src/Coordination/KeeperStorage.cpp
2026-10-01 14:19:31 +02:00
Konstantin BogdanovandClaude Opus 5.5 c4fd591112 Fix remaining assignment-in-condition findings in FuzzLoop.cpp
This code is only compiled with `USE_BUZZHOUSE`, so it was missed by
the local clang-tidy run. Fixes `bugprone-assignment-in-if-condition`
reported by `arm_tidy`, and `bugprone-assignment-in-selection-statement`
which only clang-tidy 23 reports.

https://s3.amazonaws.com/clickhouse-test-reports/PRs/121371/fc9221b6d367a40760bfc07f273e93be4067ecdd/pr/build_arm_tidy/build_clickhouse/build_clickhouse.log
PR: https://github.com/ClickHouse/ClickHouse/pull/121371

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 15:21:40 +02:00
Pedro FerreiraandClaude Opus 5 d5c70ee171 Update fuzzers
BuzzHouse gains coverage for text indexes, regular expressions, hypothetical
projections, time series, the remaining MergeTree engines, parts and
partitions, `LIMIT AFTER`/`UNTIL`, the aggregates and the `IN table` form that
were missing, and a location for Delta Lake tables. The session, table and hot
table settings lists are refreshed against master, which includes dropping
entries whose settings no longer exist.

`QueryFuzzer` is the other half of the change, extending the mutations it
applies while keeping every one of them re-parseable.

Squashed from 25 commits and 16 merges of master; the tree is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-24 08:57:38 +00:00
Alexey Milovidov 5cd66ef541 Merge pull request #112932 from ClickHouse/kql-rewrite
Reimplement the KQL (Kusto) dialect on a lexer, an AST and AST translation
2026-08-29 15:29:51 +00:00
Alexey Milovidov e263d16f0b Merge remote-tracking branch 'origin/master' into kql-rewrite
# Conflicts:
#	src/Parsers/Kusto/ParserKQLOperators.cpp
2026-08-26 05:29:21 +00:00
Ilya Yatsishin bc95467dc7 Merge remote-tracking branch 'origin/master' into ast-fuzzer-oracle
# Conflicts:
#	.github/workflows/master.yml
#	.github/workflows/pull_request.yml
2026-08-24 09:52:15 +00:00
Ilya Yatsishin 7e283a09cb Merge remote-tracking branch 'origin/master' into ast-fuzzer-oracle 2026-08-21 13:59:35 +00:00
Pedro Ferreira 8dec37fb66 Merge remote-tracking branch 'origin/master' into more-fuzz8 2026-08-19 15:45:06 +00:00
Alexey Milovidov fb8b1ca9cb Merge remote-tracking branch 'origin/master' into HEAD 2026-08-18 23:27:39 +00:00
Alexey Milovidov ec261c8cd9 KQL: address parser and timespan review feedback 2026-08-18 03:36:42 +00:00
Alexey Milovidov e8e1e12ba0 Add a style check for the spelling of ClickHouse
The product name is written `ClickHouse` - one word, with a capital `C`
and a capital `H`. Two case variants are accepted, because a mixed case
is unusable there: `clickhouse` for identifiers, package, binary and host
names, and `CLICKHOUSE` for macros and environment variables. Everything
else - `Clickhouse`, `clickHouse`, `click_house`, `CLICK_HOUSE`,
`click-house`, `Click House` - is a misspelling, and the new
`clickhouse_spelling` check of the style job reports it, in code as well
as in comments, messages, documentation and file names.

The check searches every file tracked by git, and the file names
themselves. It skips:
* `contrib` - third-party sources;
* the generated locale directories of the documentation - a machine
  translation of the English pages, which are checked instead;
* release notes - a record of what was published;
* `docs/_specs` - API specifications pinned from their generator;
* regions between `AUTOGENERATED_START` and `AUTOGENERATED_END` markers -
  their source of truth (a `FunctionDocumentation` string, for instance)
  is checked instead;
* URLs - a link whose path spells the name differently is not a mistake
  we can fix, and rewriting it would only break the link;
* the exceptions listed in `clickhouse_spelling_ignore.txt` - text that
  is not ours to spell: names defined by other projects (the
  `ClickhouseClientOptions` of our Azure SDK fork, the `clickHouse*`
  parameters of Google's Dataflow templates), verbatim quotations (Stack
  Overflow post titles shown as query output), and the misspellings that
  tests feed to the server on purpose (`LIKE` / `ILIKE` case variants, an
  unknown URI scheme).

The rest of the change fixes the 191 misspellings this found. Most are
prose and comments; the renamed identifiers are `isClickhouseApp`,
`getClickhouseAttemptNumber` / `setClickhouseAttemptNumber`,
`getClickhouseTableSchemaById` / `hasClickhouseTableSchemaById`, the
`Clickhouse*` classes of `clickhouse-diagnostics`, the `tabClickhouse` /
`btnQueryClickhouse` element ids of the `utils` web tools, and
`clickHousePartsInserter.js`. Three of them are visible to tests: the
`X-Clickhouse-Format` HTTP header, the `SOURCE(Clickhouse(...))`
dictionary source and a directory named `Clickhouse`; the first two are
matched case-insensitively by the server (Poco header collections are
case-insensitive, and the parser lowercases the source name), which I
confirmed against a running server.

The rule is also written down in the style guide.
2026-08-15 02:44:49 +00:00
Alexey Milovidov ffb9428947 KQL: address join and mv-expand review findings 2026-08-14 04:04:27 +00:00
Pedro Ferreira cbb7319d48 Fix for oracle 2026-08-12 12:34:38 +00:00
Alexey Milovidov 18b16fb855 Merge remote-tracking branch 'origin/master' into kql-rewrite 2026-08-04 04:06:06 +00:00
Alexey Milovidov 4b3692a5d5 Merge remote-tracking branch 'origin/master' into ast-fuzzer-oracle
Conflicts:
- `.github/workflows/pull_request.yml`: took master's regenerated `needs`
  list (which gained `build_profile_diff`) and re-added this PR's
  `ast_fuzzer_amd_release_oracle` job.
- `src/Interpreters/executeQuery.cpp`: master wrapped the fuzzed query
  execution in a `ThreadGroupSwitcher`; this PR moved that execution into
  an inner scope so the `BlockIO` callbacks are destroyed before the
  oracle runs. Kept both: the switcher is now declared outside the inner
  scope so it also covers the oracle's nested queries, which run on the
  same `fuzz_context`.

Also moved the `ast_fuzzer_oracle` entry in `SettingsChangesHistory` from
the released 26.7 block to the current 26.8 block.
2026-08-03 12:07:28 +00:00
Alexey Milovidov 003867cd96 Remove the KQL (Kusto) dialect implementation
The dialect was contributed in 2022 and abandoned by its authors; the
rewrite they promised in #62668 was closed unmerged.  Since then it has
been emergency-disabled once (#59305) and gated behind
`allow_experimental_kusto_dialect` (#74224), and issue #61742 ("Remove
KQL support if this code will not be fixed") has stayed open.

The implementation translated a KQL token stream directly into
ClickHouse SQL *text* and re-parsed it.  Everything below follows from
that:

  - KQL string literals were spliced into generated SQL unescaped, so
    `T | where s contains "x') OR 1 = 1 OR ilike(s, 'y"` injected
    arbitrary expressions -- and `contains '50%'` matched `'50x'`
    because LIKE metacharacters passed through.
  - No types were available while translating, so 14 sites emitted
    runtime `toTypeName()` dispatch and datetimes were modelled as
    strings truncated to 27 characters.
  - Arguments were SQL text, so a dozen sites called `std::stoi` on it;
    `format_timespan(col, 'hh:mm')` failed with "stoi: no conversion".
  - 28 of the 237 registered functions were stubs that returned the raw
    KQL name into the generated SQL, including every `series_*`.
  - `let` bindings lived in a `static thread_local` map that, by its own
    comment, leaked between unrelated queries.

This commit removes the implementation and every trace of it: the
parser, the `kusto` dialect and its experimental setting, the `kusto`
value of `interval_output_format` and the interval serialization it
drove, the client/server call sites, the fuzzer and style-check
carve-outs, and the tests.  A correct implementation is added next.

Two notes on what was deliberately kept.  `ASTSelectQuery::normalize
ChildrenOrder` stays -- several other parsers use it -- with its comment
generalized.  `04305_parser_error_message_oob_101143.sh` stays as a
regression test for the error-formatter buffer overflow; its rationale
is rewritten, since the parser it originally exercised is now gone.

Release history in CHANGELOG.md, docs/changelogs/ and
SettingsChangesHistory.cpp is left untouched.
2026-08-01 14:08:24 +00:00
Alexey MilovidovandClaude Fable 5 c776aa7a39 Address review: carry the server-side fuzzed query in oracle mismatch exceptions
With `ast_fuzzer_runs > 0` the server mutates the client's seed query again,
and the `AST_FUZZER_ORACLE_MISMATCH` exception reaching the client did not
carry that final fuzzed query — the CI artifact (`fuzzer.log`) omitted the
real reproducer. Rethrow the mismatch with the server-side fuzzed query
appended, and label the client-side seed clearly in `FuzzLoop`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 04:06:01 +00:00
Pedro Ferreira 4687717c91 Add remote and wrapped table engines to BuzzHouse, File engine tables for dolor with more formats and whole-file compression, missing AST features, scale-aware DateTime ranges and missing server properties 2026-07-22 15:44:51 +00:00
Ilya Yatsishin 10e4ec1c76 Merge remote-tracking branch 'origin/master' into ast-fuzzer-oracle
# Conflicts:
#	.github/workflows/pull_request.yml
2026-07-16 14:32:24 +00:00
Pedro Ferreira 0358632092 Fixes 2026-07-15 10:14:30 +00:00
Ilya Yatsishin 54200dd4a4 Merge remote-tracking branch 'origin/master' into ast-fuzzer-oracle
# Conflicts:
#	.github/workflows/master.yml
#	.github/workflows/pull_request.yml
2026-07-13 06:34:23 +00:00
Nikita Fomichev 7f6c08d896 Merge pull request #109725 from ClickHouse/fix-ast-fuzzer-silent-early-exit
Fix AST fuzzer silently burning the corpus and exiting early with success
2026-07-09 20:00:08 +00:00
Ilya Yatsishin 44dc2d7597 Merge remote-tracking branch 'origin/master' into ast-fuzzer-oracle 2026-07-09 12:17:02 +00:00
Nikita Fomichev 098560ada8 Fix AST fuzzer silently burning the corpus and exiting early with success
The client-side AST fuzzer loop swallowed every exception thrown during a
fuzzing step: the `catch (...)` handler recorded the error, the loop bottom
reset it, and fuzzing continued. When the failure mode is persistent - most
importantly a dead server, where the reconnection attempt inside
`processParsedSingleQuery` throws instantly - the client sprints through the
remaining corpus at hundreds of steps per second without contacting the
server and exits with code 0, which the job reports as "Fuzzer exited with
success".

Evidence from `AST fuzzer (amd_debug, targeted)` on PR #109061
(https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=109061&sha=1419f6b7e95c81c812f945c06333998b92d56ad3&name_0=PR&name_1=AST+fuzzer+%28amd_debug%2C+targeted%29):
`fuzzer.log` records 68972 fuzzing steps, of which 52837 produced no outcome
(silent exception), while `server.log` shows the server received only 209
queries within a 47-second window before dying. On PR #106250
(https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106250&sha=latest&name_0=PR&name_1=AST+fuzzer+%28amd_debug%2C+targeted%29)
a 5-file corpus with ~20 SELECT statements (about 20000 fuzzing steps, over
an hour of work at the measured debug-build rate of 2-6 steps/s) "completed"
in 74 seconds and the job passed. Overall, 13-33% of targeted AST fuzzer
runs per month finish in under 8 minutes of their 30-minute budget.

Client fixes (`programs/client/FuzzLoop.cpp`):
- Print thrown exceptions in the fuzzing-step catch handlers instead of
  swallowing them silently, so `fuzzer.log` shows what actually happened.
- After a thrown exception, check the connection via `tryToReconnect` (the
  same check `processASTFuzzerStep` does for errors received without
  throwing) and stop fuzzing when the server is gone instead of uselessly
  sprinting through the rest of the corpus.
- Register query parameters generated by `QueryFuzzer` (from
  `getLastQueryParameters`) for client-side substitution, mirroring the
  server-side fuzzer in `executeASTFuzzerQueries`; previously any fuzzed
  query containing a substituted `{name:type}` parameter failed with
  "Substitution ... is not set" before reaching the server.

Job fix (`ci/jobs/scripts/fuzzer/run-fuzzer.sh`):
- When the AST fuzzer walks the whole corpus and exits 0 with a meaningful
  part of the FUZZ_TIME_LIMIT budget remaining, restart it (each pass uses a
  fresh random seed) instead of ending the job after a couple of minutes.
  This matters for the targeted variant, whose corpus is a handful of test
  files. The restart is gated on a server liveness probe so a dead server
  still terminates the job for classification.
2026-07-08 00:25:50 +02:00
Ilya YatsishinandClaude Opus 4.8 a74b6d11c3 AST fuzzer correctness oracle
Add a correctness-oracle mode to the AST fuzzer (`ast_fuzzer_oracle`) that runs
metamorphic checks on each successfully-executed fuzzed query and raises
`AST_FUZZER_ORACLE_MISMATCH` when a rewrite that must preserve results does not:

- TLP (Three-Valued Logic Partitioning) for WHERE / HAVING / DISTINCT: a query
  and its `p` / `NOT p` / `p IS NULL` partition-union must return the same rows.
- NoREC-style aggregate/count equivalences.
- Rewrites over GROUP BY (incl. ROLLUP/CUBE/GROUPING SETS/WITH TOTALS), JOINs,
  and aggregate-state combinators.

`QueryOracleChecker` performs the checks with fail-closed guards
(`isSafeForOracle`) so non-deterministic, session-stateful, or otherwise unsafe
shapes are skipped rather than reported. `QueryFuzzer` gains oracle-shaped
mutation generation; `executeQuery` runs the oracle after the fuzzed query in an
inner scope so result callbacks are released first. Includes the client
`FuzzLoop`, the setting + error code, CI wiring (`ast_fuzzer_job`, workflow
needs-lists, run-fuzzer tweaks), and regression tests.

Squashed and rebased on latest master.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-06 15:25:57 +00:00
Pedro Ferreira 02e0d67cbc Compilation fix and remove redundant oneof fields 2026-07-03 07:21:59 +00:00
Pedro Ferreira 43a3312381 Address review comments 2026-07-02 18:43:54 +00:00
Pedro Ferreira de33a4356d Hypothetical indexes in BuzzHouse 2026-07-02 09:40:52 +00:00
Pedro Ferreira 1608b44e1b Defensive lines 2026-06-16 10:59:54 +00:00
Pedro Ferreira 41a4ce052c Better fixes and format 2026-06-16 10:40:23 +00:00
Pedro Ferreira 5d06bef25a Update probs 2026-06-15 16:27:04 +00:00
Pedro Ferreira 4cd71e12a2 More coverage for alias engine 2026-06-15 16:13:56 +00:00
Pedro Ferreira eaf0eeca19 Merge remote-tracking branch 'origin/master' into more-fuzz2 2026-06-10 07:57:44 +00:00
Pedro Ferreira 3b8f3026f1 Don't send too large queries to the server 2026-06-09 07:58:56 +00:00
Pedro Ferreira ad56cbdc30 Implement new array join oracle and fixes 2026-06-08 12:26:45 +00:00
Pedro Ferreira 2e3f9b9248 Update probabilities 2026-06-08 09:56:24 +00:00
Pedro Ferreira d7e6267695 Check if enabled 2026-06-05 15:55:20 +00:00
Pedro Ferreira cdfa41a694 format and new dump table oracle options, let's test 2026-06-05 15:35:49 +00:00
Alexey Milovidov 63e9c2d27b Merge remote-tracking branch 'origin/master' into fix-compiler-warnings
# Conflicts:
#	src/AggregateFunctions/fuzzers/aggregate_function_state_deserialization_fuzzer.cpp
#	src/Client/BuzzHouse/AST/SQLProtoStr.cpp
#	src/Functions/UserDefined/UserDefinedWebAssembly.cpp
#	src/IO/examples/parse_int_perf.cpp
#	src/Processors/QueryPlan/Optimizations/removeUnusedColumns.cpp
#	src/TableFunctions/TableFunctionMergeTreeAnalyzeIndexes.cpp
2026-05-29 02:17:22 +00:00
Pedro Ferreira af129fdbe0 Address review comments 2026-05-21 15:41:24 +00:00
Pedro Ferreira 089289466b Fix for dictionaries dump oracle 2026-05-19 18:24:06 +00:00
Alexey Milovidov 1085d7199b Merge remote-tracking branch 'origin/master' into fix-compiler-warnings 2026-05-19 15:05:56 +00:00
Pedro Ferreira 38bffe72af Generate Paimon tables in Spark 2026-05-14 14:08:05 +00:00
Pedro Ferreira 03b40afe7d Format, compilation fix and review comments 2026-05-14 12:22:56 +00:00
Pedro Ferreira 99dcc38087 Use dump table oracle for views and dictionaries 2026-05-13 16:29:34 +00:00
Alexey Milovidov f7cbbbb531 Merge remote-tracking branch 'origin/master' into fix-compiler-warnings
# Conflicts:
#	src/Interpreters/InterpreterDropQuery.cpp
#	src/Processors/QueryPlan/Optimizations/optimizeLazyMaterialization.cpp
2026-04-09 20:13:51 +00:00