Skip to content

Add embedded documentation for data types - #106180

Merged
nikitamikhaylov merged 10 commits into
masterfrom
datatype-documentation
Jun 12, 2026
Merged

nikitamikhaylov merged 10 commits into
masterfrom
datatype-documentation

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented May 31, 2026 •

Copy link
Copy Markdown
Member

Third PR in the series that adds embedded, runtime-introspectable documentation to ClickHouse component registries (after table engines #106177 and database engines #106178). This one does it for data types.

What it does:

  • Threads the shared Documentation struct (src/Common/Documentation.h, introduced in Add embedded documentation for table engines #106177) through the four DataTypeFactory::register* methods, stores it in a per-family map, and adds a getDocumentation accessor.
  • system.data_type_families now exposes description, syntax, examples, introduced_in, and related columns (previously only name, case_insensitive, alias_to).
  • For each data type with a dedicated page under docs/en/sql-reference/data-types/, the complete Markdown body is embedded verbatim into description, so the standalone Markdown files can later be dropped and regenerated.
  • Several pages document a whole group of families (e.g. int-uint.md covers all integer types, float.md the floats, decimal.md the decimals, geo.md the geo types, interval.md the intervals). In that case the full page is embedded into one representative family — Int32, Float64, Decimal, IntervalDay, Point — and the other families in the group get a concise description that references the representative. This keeps one page per file for later regeneration.

Implementation note: the JSON documentation exceeds the 65536-byte string literal length that C++ compilers are required to support, so its description is concatenated at runtime from several smaller string literals.

Note: this PR shares src/Common/Documentation.h/.cpp with #106177 and #106178 (trivial add/add on merge).

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Data types now carry embedded documentation, introspectable via the new description, syntax, examples, introduced_in, and related columns of the system.data_type_families table.

Documentation entry for user-facing changes

  • Documentation is provided as part of this change (embedded documentation in system.data_type_families and an updated system.data_type_families system-table page).

Version info

  • Merged into: 26.6.1.710

Attach the shared `Documentation` struct (introduced for table engines) to data
type families via the `DataTypeFactory::register*` methods, store it in a
per-family map, and expose `description`, `syntax`, `examples`, `introduced_in`,
and `related` columns on `system.data_type_families`.

For data types that have a dedicated documentation page under
`docs/en/sql-reference/data-types/`, the complete Markdown body of that page is
embedded verbatim into the `description` field, so the standalone Markdown files
can later be dropped and regenerated from the embedded documentation. Several
pages document a whole group of families at once (e.g. `int-uint.md` covers all
integer types); in that case the full page is embedded into one representative
family (`Int32`, `Float64`, `Decimal`, `IntervalDay`, `Point`) and the other
families in the group get a concise description that references it.

The `JSON` documentation exceeds the 65536-byte string literal length that C++
compilers are required to support, so its `description` is concatenated at
runtime from several smaller string literals.

This is a follow-up to the same change for table engines and database engines and
reuses the `Documentation` struct from `src/Common/Documentation.h`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8caa7f7]

Summary: ✅


AI Review

Summary

This PR embeds data type documentation into DataTypeFactory registrations and exposes it through new system.data_type_families columns. The factory and system-table plumbing look consistent, and the prior review threads are fixed in the current code, but one migrated FixedString documentation block is still malformed as runtime Markdown.

Findings

⚠️ Majors

  • [src/DataTypes/DataTypeFixedString.cpp:143] The FixedString description is now exposed through system.data_type_families.description, but this sql code fence includes response payloads and client transcript text such as Query id: c32cec28-bb9e-4650-86ce-d74a1694d79e and 0 rows in set.. Users and renderers will treat those lines as SQL, so the example is copy-paste-invalid and misleading.
    Suggested fix: split the transcript into separate sql query fences and text response fences, or mark the whole block as plain text if it is intentionally a terminal transcript.
Final Verdict

Status: ⚠️ Request changes

Minimum required action: fix the malformed FixedString embedded documentation block.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label May 31, 2026
Comment thread src/DataTypes/DataTypeObject.cpp Resolved
alexey-milovidov and others added 2 commits June 1, 2026 05:37
The embedded Markdown for several data types contained trailing
whitespace and a double space after a comma in a JSON example, which
the `whitespace_check` and `cpp` style checks reject.

Additionally, the `JSON` description embedded Docusaurus-only MDX
(`import` statements, `<Link>`, `<CardSecondary>`, and `<WhenToUseJson />`)
that renders as noise when introspected through
`system.data_type_families.description` and tripped the abbreviation
check on the `WhenToUseJson` token. Replaced the "Looking for a guide?"
card with a plain `:::tip` admonition that keeps the link, and dropped
the website-only components.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The example queried `SELECT *` but its rendered output only shows the
three pre-existing columns `name`, `case_insensitive`, and `alias_to`.
With the new `description`, `syntax`, `examples`, `introduced_in`, and
`related` columns the displayed result shape would be stale, so the
query now selects those three columns explicitly.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Comment thread src/DataTypes/DataTypeDynamic.cpp Resolved
Comment thread src/DataTypes/DataTypeInterval.cpp Resolved
Comment thread src/DataTypes/DataTypeCustomGeo.cpp Resolved
Comment thread src/DataTypes/DataTypesNumber.cpp Resolved
Comment thread src/DataTypes/DataTypeDynamic.cpp Resolved
alexey-milovidov and others added 3 commits June 2, 2026 18:09
The `Style check` (`cpp`) was failing on the embedded data type
documentation, and the AI/Bugbot review flagged several malformed or
inaccurate embedded Markdown fragments now exposed through
`system.data_type_families.description`.

Style fixes:
- De-indent embedded Markdown code fences and ASCII-art tables to
  column 0 (matching the established `FunctionDocumentation` convention,
  e.g. `FunctionChar.cpp`). The original `.md` pages used list-attached
  2-3 space indentation, which the C++ indentation check rejects.
- Remove non-idiomatic whitespace immediately inside parentheses in a
  few prose/SQL lines (e.g. `Nullable( Enum8(...) )` -> `Nullable(Enum8(...))`,
  `( -1 * 10^(P - S), ... )` -> `(-1 * 10^(P - S), ...)`), which tripped
  the parenthesis-spacing check.
- Drop the exclamation mark in the `JSON` example values
  (`"Hello, World!"` -> `"Hello, World"`), which tripped the `!",` check.

Content-accuracy fixes (review feedback):
- `DataTypeDynamic`: move the stray closing code fence off the `SELECT`
  line, and fix the result-table header `v`/`dynamicType(v)` to match the
  query's `d`/`dynamicType(d)`.
- `DataTypeVariant`: remove the stray leading-space closing fence.
- `DataTypeCustomSimpleAggregateFunction`: de-duplicate the blog bullet
  in `Related Content`.
- `DataTypeInterval`: make the comparison example reproducible by
  aligning the query with the shown response
  (`toIntervalMicrosecond(179999999) < toIntervalMinute(3)`).
- `DataTypeCustomGeo`: fix the `LineString` response header to use
  `l`/`toTypeName(l)` instead of the `Ring` columns `r`/`toTypeName(r)`.
- `DataTypesNumber`: align the integer alias table with the registered
  aliases (`TIME` is not an `Int64` alias; `YEAR` is a `UInt16` alias).
- Remove the spurious `1.`/`2.`/`3.` numbered-list prefixes that had
  leaked into the embedded table output rows, which left the tables
  misaligned once the surrounding indentation was removed.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106180&sha=793416006029d4058aa8525b151e46fb271c32f3&name_0=PR&name_1=Style%20check
PR: #106180

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The embedded documentation for the `Dynamic` and `Variant` data types
had a closing Markdown fence appended directly to the end of a `SELECT`
query line, so the SQL exposed verbatim through
`system.data_type_families.description` was copy-paste-invalid and the
rendered code block was malformed. Move the closing fence onto its own
line (a correct standalone fence already followed each query line).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Continued this PR:

  • Addressed the remaining clickhouse-gh review thread (stray closing Markdown fence inside SQL example lines). Commit 3544ff3 moves the closing fence off the SELECT ... AS dynamic_types line in DataTypeDynamic.cpp and the SELECT ... AS map_of_variant_types line in DataTypeVariant.cpp. Verified against the rebuilt binary that system.data_type_families.description now renders both fences on their own line, and swept all ``` occurrences across the embedded DataTypes/*.cpp docs — the only remaining non-standalone fences are valid info-string fences (e.g. ```sql title="Query").
  • Merged master (was 1370 commits behind; shared Common/Documentation.h/.cpp with Add embedded documentation for table engines #106177/Add embedded documentation for database engines #106178 merged trivially with no conflicts).
  • Rebuilt clickhouse cleanly and re-ran the checks: 04301_data_type_families_documentation matches its reference, and the system.data_type_families column set matches the updated 02117_show_create_table_system.reference.

CI failures on the previous commit are unrelated to this documentation-only change:

  • AST fuzzer (amd_debug) — Logical error: Column identifier A is already registered (STID: 4697-4326). Exact STID match to the already-tracked Logical error: Column identifier A is already registered (STID: 4697-4326) #99931; the reproducer is lightweight DELETE over a MergeTree table and the stack is entirely in Planner/analyzer code, with no relation to data-type documentation.
  • Integration tests — test_s3_aws_sdk_has_slightly_unreliable_behaviour::test_dataloss timed out after 600s; the known flaky S3 SDK timeout, unrelated to this PR.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Continued this PR:

  • Merged master (was 464 commits behind; clean merge with no conflicts). The shared Common/Documentation.h/.cpp are now identical to master (siblings Add embedded documentation for table engines #106177/Add embedded documentation for database engines #106178 are merged), so they no longer appear in the diff.
  • Rebuilt clickhouse cleanly and re-verified the checks: 04301_data_type_families_documentation matches its reference, and the system.data_type_families column set (name, case_insensitive, alias_to, description, syntax, examples, introduced_in, related) matches 02117_show_create_table_system.reference.

No unresolved review threads remain; the AI review is Approve.

The only red CI signal is the Performance Comparison, and it is noise unrelated to this documentation-only change: all flagged queries (rand, general_purpose_hashes, parallel_hash_join_various, insert_select_default_small_block) fail on both ::old and ::new (the measurement-noise signature), and the machine-readable report classifies them as unstable with the verdict "No significant performance changes detected". Embedding Markdown string literals into DataTypeFactory registrations cannot affect query execution performance.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

Continued this PR:

  • Merged master (was 348 commits behind; clean merge with no conflicts). The shared Common/Documentation.h/.cpp remain identical to master (siblings Add embedded documentation for table engines #106177/Add embedded documentation for database engines #106178 merged), so they do not appear in the diff.
  • Rebuilt clickhouse cleanly (no errors) and re-verified the checks against the new binary: 04301_data_type_families_documentation matches its reference, and the system.data_type_families column set (name, case_insensitive, alias_to, description, syntax, examples, introduced_in, related) matches 02117_show_create_table_system.reference.

No unresolved review threads remain; the AI review is Approve. The previously red CI signal on the prior commit consisted of stale 0s jobs that were aborted/superseded by the master merge; the fresh push re-triggers CI.

alexey-milovidov and others added 2 commits June 10, 2026 10:30
…d collisions

Master gained other 04301_* tests, so the test from this PR is renamed
to the next free number.

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

Merged master into the branch (clean, no conflicts) and renamed the test 04301_data_type_families_documentation to 04327_data_type_families_documentation, since master gained several other 04301_* tests in the meantime.

The single red check on the previous head, AST fuzzer (amd_tsan) — Logical error: Column identifier A is already registered on a lightweight DELETE with EXISTS subqueries — is unrelated to this documentation-only PR. It is the known analyzer/mutations issue #106649, with fixes already in progress: #106414 and #106025.

- If equality operator `=` or `==` or `equals` function used, ClickHouse _doesn't_ take `\0` char into consideration, i.e. queries `SELECT * FROM FixedStringTable WHERE name = 'a';` and `SELECT * FROM FixedStringTable WHERE name = 'a\0';` return the same result.
- If `LIKE` clause is used, ClickHouse _does_ take `\0` char into consideration, so one may need to explicitly specify `\0` char in the filter condition.

```sql

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.

This FixedString description is now returned verbatim through system.data_type_families.description, but the block opened as sql includes response payloads and client transcript lines ({"name":"a\u0000"}, Query id: c32cec28-bb9e-4650-86ce-d74a1694d79e, 0 rows in set.). Renderers and users copying the block will treat that output as SQL. Please split the transcript into separate sql query and text response fences, or mark the whole block as plain text if it is intended as a transcript.

@clickhouse-gh

clickhouse-gh Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.60% 84.70% +0.10%
Functions 92.30% 92.40% +0.10%
Branches 77.30% 77.30% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 4687/4687 (100.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 7 line(s) · Uncovered code

Full report · Diff report

@nikitamikhaylov nikitamikhaylov self-assigned this Jun 12, 2026
@nikitamikhaylov
nikitamikhaylov added this pull request to the merge queue Jun 12, 2026
Merged via the queue into master with commit cdfc0dc Jun 12, 2026
166 checks passed
@nikitamikhaylov
nikitamikhaylov deleted the datatype-documentation branch June 12, 2026 13:19
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants