Repository navigation
Make SQL examples in embedded documentation runnable - #108556
Conversation
Many query/response examples embedded in `system.documentation` (rendered from the inline `FunctionDocumentation`/`Documentation` in the source) did not run as written. This makes them runnable and self-contained: - Add `SET <setting> = 1;` to examples that require a non-default setting: experimental TimeSeries aggregate functions (`allow_experimental_time_series_aggregate_functions`), `enable_nullable_tuple_type` (`RowBinary`), deprecated snowflake/window functions, the experimental `Dynamic`/`Variant` types, and `variant_throw_on_type_mismatch` for the functions-with-`Variant`-arguments examples. - Duplicate the dictionary creation (source table + `CREATE DICTIONARY` with a local `SOURCE(CLICKHOUSE(...))`) into every `dictGet*` example so each is self-contained. - Fix genuine bugs: `emptyArray*` missing `()`; a table named with the reserved word `table` in `hasAllTokens`/`hasAnyTokens`; stale `toTime`/`toTime64` signatures; missing training data for `stochasticLinearRegression`/ `stochasticLogisticRegression`; non-deterministic `arrayJoin` examples (added `ORDER BY`). Affected responses were regenerated. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [52b6ebc] Summary: ✅
AI ReviewSummaryThis PR is a documentation-only pass over embedded Final VerdictStatus: ✅ Approve No minimum required actions. |
| Using `Dynamic` type in table column definition: | ||
|
|
||
| ```sql | ||
| SET allow_experimental_dynamic_type = 1; |
There was a problem hiding this comment.
It is the default, we don't need this setting.
There was a problem hiding this comment.
Done in facdf54 — removed. allow_experimental_dynamic_type is obsolete (default-on now), so the example runs without it.
| Using `Variant` type in table column definition: | ||
|
|
||
| ```sql | ||
| SET allow_experimental_variant_type = 1; |
There was a problem hiding this comment.
It is the default, we don't need this setting.
There was a problem hiding this comment.
Done in facdf54 — removed for the same reason (allow_experimental_variant_type is obsolete/default-on). Kept variant_throw_on_type_mismatch = 0 only where an example relies on the NULL-for-incompatible behavior.
| )", | ||
| R"( | ||
| 14:30:25 | ||
| 1970-01-02 14:30:25 |
There was a problem hiding this comment.
We should enable something so that this function returns Time
There was a problem hiding this comment.
Done in facdf54 — added SET use_legacy_to_time = 0 (plus enable_time_time64_type = 1) so toTime returns Time; the responses are updated to the Time value (14:30:25).
- Dynamic/Variant: remove `SET allow_experimental_dynamic_type`/ `allow_experimental_variant_type` — both are obsolete (default-on now). - `toTime`: enable `Time` output via `SET use_legacy_to_time = 0` (+ `enable_time_time64_type = 1`); responses updated to the `Time` value. - `toTime64`: fix structured syntax to `toTime64(x, scale)` and add the `scale` argument; add `SET enable_time_time64_type = 1` to the examples. - `dictGet*` examples: use `DB currentDatabase()` instead of hard-coded `DB 'default'` so they work in any current database. - `stochasticLinearRegression`/`stochasticLogisticRegression`: make every example self-contained (each creates its own training data/model). - `getClientHTTPHeader`: show an explicit HTTP request (the function reads request headers, so it only returns a value over the HTTP interface). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…nistic Following the AI review on the PR: - `hasAnyTokens`/`hasAllTokens`: each `FunctionDocumentation::Examples` entry is rendered by `examplesAsString` as its own query block, but several entries only ran `SELECT ... FROM doc`/`FROM log` and relied on a previous entry to create the table, so they failed with `UNKNOWN_TABLE` when run independently. Duplicated the `CREATE TABLE`/`INSERT` setup into every dependent entry (matching the `dictGet*` approach in this PR) so each block is self-contained. - `toTime`: the integer-to-`Time` example used `toDateTime(52225)`, whose result depends on the server time zone, so the documented `14:30:25` only held on a UTC server. Made the source time zone explicit with `toDateTime(52225, 'UTC')` so the example is deterministic. - `dictGetKeys`: the example compared the exact array order `[4,2]`, but `dictGetKeys` returns keys in dictionary scan order (`HASHED` iterates hash containers), which is not a documented guarantee. Wrapped the result in `arraySort` and updated the expected output to `[2,4]`. Verified each changed example runs in `clickhouse-local`, including the `toTime` case under non-UTC time zones. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- `toTime64`: return type documented as `Time64` (was `Time64(6)`) since the result scale follows the `scale` argument. - `toTime`: add `DateTime64` to the documented argument types (the example uses a `DateTime64` input). - `runningDifference`: order the example by `EventTime, EventID` so rows with equal `EventTime` have a deterministic order. - `least`/`greatest`: replace `now()` in the DateTime example with fixed literals so the documented response is reproducible. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…into docs-fix-embedded-doc-examples
The `enable_nullable_tuple_type` setting is required only to create a `Nullable(Tuple(...))` type. It had been added to 16 RowBinary examples that do not use such a type (Map, Variant, Dynamic, Point/Geometry, SimpleAggregateFunction states, QBit, ...) — all of which run without it. The one block that genuinely uses `Array(Nullable(Tuple(UInt32, String)))` (the complex-Tuple illustration) lacked the setting and failed. Remove the 16 unnecessary `SET enable_nullable_tuple_type = 1;` lines and add the setting to the block that actually needs it. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…64 unit Two issues raised in PR review on the embedded documentation examples: - `getClientHTTPHeader`: the `Example::query` stored an `echo ... | curl` shell pipeline, but `FunctionDocumentation::examplesAsString` always renders that field inside a `sql` query block, so consumers of `system.documentation` that execute the example would try to run the shell command as SQL. Moved the HTTP `curl` invocation into the description prose (a `bash` block) and made the example a valid, runnable SQL query: the empty-header case over a non-HTTP interface with `SETTINGS allow_get_client_http_header = 1`. - `toTime64`: the description said numeric arguments represent microseconds since midnight, but the implementation (`ToTime64TransformUnsigned`/`ToTime64TransformSigned` multiply the numeric value by the requested scale) and the example treat them as seconds since midnight (`toTime64(52225.123456, 6)` is `14:30:25.123456`). Updated the description to say seconds since midnight, matching `toTime`, and clarified that the precision depends on `scale`. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
@alexey-milovidov This is not caused by this PR and there is no code to fix here. It is a known fuzzer-harness false positive, already fixed on master. What happened on that run (sha 28d5e71, 2026-06-27 02:48 UTC):
This signature has 0 master hits and 7 unrelated PRs in the last 30 days, and arm_asan_ubsan passed on 3 earlier commits of this same PR, so it is transient, not a regression. Already fixed by #108582 (merged 2026-06-27 17:06 UTC), which retries on a probe timeout instead of declaring the server dead on the first one. This branch predates that merge. Merge master into the branch and re-run; the check will pass. |
…oc-examples # Conflicts: # src/Functions/snowflake.cpp
|
Merged Conflict resolution: the single merge conflict was CH Inc sync: the private sync PR had the identical Remaining red — not caused by this PR: |
|
📊 Cloud Performance Report ✅ AI verdict: This PR only edits embedded documentation examples in function/aggregate-function source files (adding CREATE TABLE/dictionary setup, SET statements, and expected outputs) — it changes no query-execution code. Neither ClickBench Q15 (-12.29%) nor Q32 (-5.03%) exercises any path this PR touches, so both deltas are run-to-run variance rather than real effects of the change. Q15's flagged improvement is downgraded to not sure, and Q32 remains not sure. No action needed from the author. clickbenchFlagged queries (2 of 43)
q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
`FunctionDocumentation::examplesAsString` renders each `Examples` entry as a separate, independently runnable SQL block. Previously only the first `timeSeriesLastTwoSamples` example created `t_raw_timeseries` / `t_resampled_timeseries_15_sec` and enabled `allow_experimental_time_series_aggregate_functions`, so the remaining three blocks failed with `UNKNOWN_TABLE` (and, for the `idelta`/`irate` examples, an experimental-function exception, since `timeSeriesInstantDeltaToGrid` / `timeSeriesInstantRateToGrid` are gated by the same setting) when run on their own. Each dependent example now prepends the setup it needs: the two re-sampled-data examples re-create both tables, the materialized view, and the insert; the raw-data `idelta`/`irate` example only re-creates and populates `t_raw_timeseries`. Every block was verified to run standalone in `clickhouse-local` and reproduce the documented output. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
@groeneai, fix |
|
|
|
Continuation triage (head Status: MERGEABLE / BLOCKED · AI Review ✅ Approve · @dhtclk APPROVED · 0 actionable unresolved threads (the 3 remaining are outdated self-notes already addressed in All 4 reds are unrelated:
No |
|
Continuation re-check (head Status unchanged since the previous pass: MERGEABLE / BLOCKED · AI Review ✅ Approve · @dhtclk APPROVED · 0 actionable unresolved threads (the 3 remaining are outdated self-notes already addressed in Independently re-verified the two stateless/fuzzer reds against CIDB (last 30d):
Re-ran the failed flaky jobs to try to flip CI green and unblock the merge. No |
|
Continuation triage (head Status: MERGEABLE / BLOCKED · AI Review ✅ Approve · @dhtclk APPROVED · 0 actionable unresolved threads (the 3 remaining are The reds shifted from the previous pass (different flakes each run, which itself confirms flakiness). All current reds are unrelated:
CH Inc sync ( Re-ran the failed flaky jobs on both the public and the private (sync) workflows to try to flip CI green. No |
|
Re-merged `master` (`52b6ebcd9de`). The PR head had drifted ~776 commits / ~2 days behind and was red only on a stress flake, so I merged master to get fresh CI on a fresh binary. Notably, master had since evolved two files this PR touches — `FunctionDictGetKeys.cpp` and `hasAnyAllTokens.cpp` — and both merged cleanly; the net diff remains doc-string-only (self-contained setup preserved, and the new The only public red on the previous head was AI Review is ✅ Approve on the previous head, and @dhtclk previously approved. Fresh CI is running on the new head and the |
|
Continuation re-check (head The fresh CI on the re-merged head has come back essentially clean. Status: MERGEABLE / BLOCKED · AI Review ✅ Approve (re-run 03:52Z on this merged head) · @dhtclk APPROVED · 0 actionable unresolved threads (the 3 remaining are The single public red is unrelated to this PR:
The failed |
|
@groeneai, fix |
|
@alexey-milovidov Confirmed: New signal that helps land the fix: #108854 is now approved (by Algunenano) and MERGEABLE. Its only failing check is one transient |
|
Continuation triage (head Status: MERGEABLE / BLOCKED · AI Review ✅ Approve (re-verified 06:34Z on this head, "No minimum required actions", no new findings) · @dhtclk APPROVED · 0 actionable unresolved threads (the 3 remaining are The sole public red is the aggregate The parent run had now completed, so I re-ran the failed
No code changes needed this pass. Blocked on: flake rerun going green (or #108854 landing) + new sync completing + your merge. |
|
Continuation (head The one public red on this head — This is the master-wide distributed-desync race (regression from #108630 Since that run had finished (no longer in-flight), I re-ran just the failed shard ( |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 1318/1318 (100.00%) · Uncovered code |
|
Continuation re-check (head CI has fully settled to green since the previous pass. Status: MERGEABLE / CLEAN · AI Review ✅ Approve (re-verified 14:17Z on this head, "No minimum required actions") · @dhtclk APPROVED · 0 actionable unresolved threads (the 3 remaining are
The diff remains doc-string-only (embedded |
PR #108556 made the SQL examples embedded in `system.documentation` runnable, but nothing runs them, so they go stale again. Add a runner that executes every one of them against a server, a CI job that provides that server, and a known-failures baseline; fix every example the runner found broken, and regenerate the documented responses that no longer match what the server prints. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…d-doc-examples Make SQL examples in embedded documentation runnable
Many query/response examples embedded in
system.documentation(rendered from the inlineFunctionDocumentation/Documentationin the source — the same content published on the website) did not run as written. This PR makes them runnable and self-contained, without changing what each example demonstrates.What changed:
SET <setting> = 1;to examples that require a non-default setting: experimental TimeSeries aggregate functions (allow_experimental_time_series_aggregate_functions),enable_nullable_tuple_type(RowBinary), deprecated error-prone window functions (allow_deprecated_error_prone_window_functions), the experimentalDynamic/Varianttypes, andvariant_throw_on_type_mismatchfor the functions-with-Variant-arguments examples.CREATE DICTIONARYwith a localSOURCE(CLICKHOUSE(...))) into everydictGet*example so each one is self-contained.emptyArray*missing(); a table named with the reserved wordtableinhasAllTokens/hasAnyTokens; staletoTime/toTime64signatures; missing training data forstochasticLinearRegression/stochasticLogisticRegression; non-deterministicarrayJoinexamples (addedORDER BY). Affected responses were regenerated to match actual output.Each fixed example was verified to run successfully in
clickhouse-localagainst a build of this branch.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Made the SQL examples embedded in
system.documentationrunnable and self-contained.Version info
26.7.1.363(included in26.7and later)