Repository navigation
Add embedded documentation for input/output formats - #106181
Conversation
Attach the shared `Documentation` struct (introduced for table engines) to formats: add a `documentation` field to `FormatFactory::Creators`, a `FormatFactory::setDocumentation` method, and expose `description`, `examples`, `introduced_in`, and `related` columns on `system.formats`. The complete Markdown body of each format's documentation page under `docs/en/interfaces/formats/` is embedded into the `description` field, so the standalone Markdown files can later be dropped and regenerated from the embedded documentation. The 95 formats that have a dedicated page get the full page; the 14 alias formats (e.g. `TSV`, `NDJSON`, `Raw`) get a concise description that references their canonical format. The documentation is populated by `registerFormatDocumentations`, called at the end of `registerFormats`. That file is generated from the Markdown pages. This is a follow-up to the same change for table engines, database engines, and data types, and reuses the `Documentation` struct from `src/Common/Documentation.h`. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Workflow [PR], commit [b4100b5] Summary: ✅
AI ReviewSummaryThis PR embeds runtime documentation for input/output formats, exposes the new Findings
Final VerdictStatus: Minimum required action: add |
`registerFormatDocumentations` runs unconditionally for every documented format, but many formats depend on optional libraries (`Avro`, `Arrow`, `Parquet`, ...) and are absent from builds configured with `ENABLE_LIBRARIES=0`, such as the fast-test build. The previous `FormatFactory::setDocumentation` used `getOrCreateCreators`, which inserted a new entry into the formats dictionary for such an unavailable format. The result was a phantom format with neither input nor output creator: it became "known but unusable", turning an `UNKNOWN_FORMAT` error into `FORMAT_IS_NOT_SUITABLE_FOR_OUTPUT`, and added a fake row to `system.formats`. This broke `03298_triger_local_error_format` in the fast-test build, where `SELECT 'a' INTO OUTFILE '/dev/null' TRUNCATE FORMAT Avro` started returning `FORMAT_IS_NOT_SUITABLE_FOR_OUTPUT` instead of `UNKNOWN_FORMAT`. `setDocumentation` now attaches documentation only to a format that is already registered in the current build, leaving the registered-format set unchanged. `04302_formats_documentation` is updated accordingly: it checks core formats that are present in every build (optional-library formats such as `Parquet` are not), and gains a regression guard asserting that no format carries documentation while being usable for neither input nor output. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`src/Formats/registerFormatDocumentations.cpp` is auto-generated and embeds the verbatim Markdown documentation of every format. That content trips the heuristic C++ style checks: the `TabSeparated`/`TSV` examples must contain literal tab characters, the `Pretty` examples contain box-drawing result tables indented by one to three spaces, and embedded SQL examples use spacing such as `( ... )` — none of which can be "cleaned" without corrupting the documentation. Exclude the file from the `whitespace_check` and `cpp` style checks, the same way `StorageSystemDashboards.cpp`, `Settings.cpp` and `FormatFactorySettings.h` (which also embed documentation/data) are already excluded. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The generated `registerFormatDocumentations.cpp` defined the function without a preceding declaration in the same translation unit, so the `-Wmissing-prototypes` diagnostic (treated as an error) broke both the `Fast test` and `Build (arm_tidy)` builds. Add a forward declaration right before the definition, matching the convention used by the other format-registration functions (e.g. `registerInputFormatCSV`). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Master added `04302_alter_segments_partition_validation`; move the formats-documentation test to the next free number. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Both red checks ( Fixed by adding a forward declaration immediately before the definition, matching the convention used by the other format-registration functions (e.g. Also merged The three open review threads (input-only |
|
The failures of They were introduced by #104690 ("Add #104690 was merged in violation of the ClickHouse team rules: its own CI already showed these two tests failing (10 times between May 12 and June 1) before it was merged. Please update your branch to pick up the revert; the tests should pass again. |
Address the review threads on the embedded format documentation exposed through `system.formats`: - `JSONL` is registered for input only, so document it as input-only and note that `SELECT ... FORMAT JSONL` is not supported (it is not an output alias of `JSONEachRow`). - `JSONStrings` is an output-only format; correct its capability table (`is_input` is false) and drop the misleading `INSERT ... FORMAT JSONStrings` example. - `JSONStringsEachRow` is registered for both input and output; correct its capability table which previously claimed input was unsupported. - `RawWithNames` / `RawWithNamesAndTypes` are aliases of the raw `TabSeparatedRaw*` formats, not of the escaped `TabSeparated*` formats; remove them from the `TabSeparatedWithNames` / `TabSeparatedWithNamesAndTypes` alias lists, and fix a stray `...AndNames` typo in the `TabSeparatedRawWithNamesAndTypes` aliases. - Expand the embedded Docusaurus MDX snippets/components (`<DataTypeMapping/>`, `<PrettyFormatSettings/>`, `<RowBinaryFormatSettings/>`, `<CloudNotSupportedBadge/>`) into self-contained Markdown so `system.formats.description` no longer exposes unresolved placeholders. - Reword the file header so it no longer points to an uncommitted generator script and instead describes the embedded text as the authoritative copy to keep in sync with the Markdown pages. The same factual corrections are mirrored into the corresponding Markdown pages under `docs/en/interfaces/formats/`, and `04305_formats_documentation` now asserts that the documented input/output capabilities of `JSONL`, `JSONStrings`, and `JSONStringsEachRow` match their `is_input` / `is_output` flags. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Merged `master` (was 953 commits behind; the shared `Common/Documentation.h`/`.cpp` add/add resolved cleanly — they now match master from the merged sibling PRs and dropped out of this diff). Pushed the previously-local accuracy-fix commit `08f8e6de076` together with the merge. All six review threads on
Test |
… in embedded `Avro` documentation Two fixes in both the source Markdown (`docs/en/interfaces/formats/Avro/Avro.md`) and the generated `src/Formats/registerFormatDocumentations.cpp`: - The Avro specification link still contained the docs-site placeholder `++version++`, which is invalid when the page is exposed verbatim via `system.formats.description`. Replaced with the stable `current` alias of the Apache Avro documentation. - The `DESCRIBE url(...)` example was missing the closing quote of the `'Avro'` string literal, making the example invalid SQL when copied. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Status update:
All CI failures at
@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106181&sha=ba5563813c3621de8e414d0658aef7fc0227aca1&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20old%20analyzer%2C%204%2F6%29 ( |
|
@alexey-milovidov Investigated Root cause:
CIDB: this specific test failed 1x in 30 days (PR #106181 itself, doc-only, so not its cause). The suite's other 17 PR hits are spread across 3 different tests that look like separate timing issues. Fix options: If you confirm A, I will build a deterministic repro (inject a small post-EOF delay in the child to widen the window), show it fails on HEAD and passes with the bounded reap, and open a separate PR. No open issue exists for this. (session cron:clickhouse-worker-slot-6:20260612-001600) |
Previously the embedded documentation of every input/output format lived in a single generated file `src/Formats/registerFormatDocumentations.cpp`, attached at the end of `registerFormats` via `registerFormatDocumentations`. Per review feedback, the documentation for each format should live in the same source file as the format itself. This distributes all 110 `factory.setDocumentation(...)` calls from the single generated file into the `register*Format*` functions of the corresponding format source files under `src/Processors/Formats/Impl/`, and removes the generated file along with its declaration and call in `registerFormats`. The documentation is now attached right after each format registers, so it is co-located with the format and naturally guarded by the same optional-library `#if` conditions (`USE_ARROW`, `USE_PROTOBUF`, etc.). The contents of `system.formats` are unchanged. To keep the verbatim Markdown documentation embedded as `R"DOCS_MD( ... )DOCS_MD"` raw-string literals from tripping the heuristic C++ style checks, the checks are made smarter rather than excluding whole files: a new helper `ci/jobs/scripts/check_style/filter_embedded_docs.py` drops style-check hits that fall inside those raw strings, and `check_whitespaces` skips them directly. This covers literal tabs (`TabSeparated`/`TSV` examples), `Pretty` result tables indented by one to three spaces, and trailing whitespace inherited from the Markdown pages. The previous blanket exclusion of `registerFormatDocumentations.cpp` from the style checks is removed. Co-Authored-By: Claude Opus 4.8 <[email protected]>
`JSONL` was registered for input only, while its sibling newline-delimited JSON aliases `JSONLines` and `NDJSON` work for both input and output. There is no reason for `JSONL` to be input-only. Register `JSONL` for output as well (in `registerOutputFormatJSONEachRow`, with the same parameters as `NDJSON`) and mark it as supporting a subset of columns on input, so it behaves identically to `JSONEachRow`, `JSONLines`, and `NDJSON`. Now `SELECT ... FORMAT JSONL` works. Update the embedded and standalone documentation accordingly (`JSONL` is now a plain alias and the note that `SELECT ... FORMAT JSONL` is unsupported is removed), and update `04305_formats_documentation` to assert `is_output = 1` for `JSONL`. Add `04337_jsonl_input_output_format` as a functional round-trip guard for both directions. Addresses the review thread on `docs/en/interfaces/formats/JSON/JSONLines.md` for #106181. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…alias
The previous commit registered `JSONL` as an output format. `FormatFactory::registerOutputFormat` auto-registers a file extension equal to the lower-cased format name, so this re-pointed the `jsonl` file extension from `JSONEachRow` to `JSONL`, undoing the explicit `jsonl` -> `JSONEachRow` mapping set in `registerInputFormatJSONEachRow` (the output registration runs after the input one). Because `JSONL` had no schema reader, reading any `.jsonl` file then failed with `JSONL file format doesn't support schema inference. You must specify the structure manually.` (`BAD_ARGUMENTS`), breaking `02375_system_schema_inference_cache`, `02268_json_wrong_root_type_in_schema_inference`, `02571_local_desc_abort_on_twitter_json`, `03228_clickhouse_local_copy_argument`, and `02816_clickhouse_local_table_name_expressions`.
Two fixes:
- Register a schema reader for `JSONL` so it behaves identically to `JSONEachRow`, `JSONLines`, and `NDJSON` for explicit `FORMAT JSONL` schema inference (the previous commit added `markFormatSupportsSubsetOfColumns("JSONL")` but not the schema reader).
- Re-assert the `jsonl` -> `JSONEachRow` extension mapping at the end of `registerOutputFormatJSONEachRow` (which runs after the input registration), so files with a `.jsonl` extension are still resolved to the canonical `JSONEachRow` format, matching the existing `02375_system_schema_inference_cache` reference.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ables Following the review threads on making `JSONL` a full input/output alias of `JSONEachRow`: - Register the file segmentation engine and the non-trivial prefix/suffix checker for `JSONL` (in `registerFileSegmentationEngineJSONEachRow` and `registerNonTrivialPrefixAndSuffixCheckerJSONEachRow`), so `JSONL` has the same ancillary registrations as `JSONEachRow`, `JSONLines`, and `NDJSON`. - List `JSONL` in the `JSONEachRow` alias table, both in the embedded documentation and in the standalone `docs/en/interfaces/formats/JSON/JSONEachRow.md`, keeping the alias tables in sync. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`JSONL` became a full input/output alias of `JSONEachRow` (like `JSONLines` and `NDJSON`) earlier in this branch, so it is now reported by `system.formats` with `is_output = 1` and is enumerated by the `WHERE is_input AND is_output` queries that drive `02187_async_inserts_all_formats` and `03251_insert_sparse_all_formats`. Both tests started failing because `JSONL` appears in the format list (sorted between `JSONEachRow` and `JSONLines`) but was missing from their reference files. As a pure alias of `JSONEachRow`, `JSONL` round-trips identically, so the new lines carry the same universal hash (`9260153077572524277`) in `03251`. Verified locally: the round-trip through `JSONL` yields that hash, `JSONL` output is byte-identical to `JSONLines`, and `JSONL` lands between `JSONEachRow` and `JSONLines` in both tests' format queries. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…docs The embedded `system.formats` documentation and the `is_input`/`is_output` flags already report `LineAsStringWithNames` and `LineAsStringWithNamesAndTypes` as output-only, but the standalone documentation disagreed: `LineAsStringWithNames.md` had `input_format: true`, and the overview table in `formats.md` listed both variants as input/output. That left the docs guiding users toward `INSERT ... FORMAT LineAsStringWithNames`, which throws. Set `input_format: false` in `LineAsStringWithNames.md` (the `...AndTypes` page was already correct) and change both overview rows in `formats.md` to output-only (`✗` / `✔`) so the documentation matches the registration. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ly docs `JSONCompactStringsEachRowWithProgress` is registered output-only and its capability table already shows `Input = ✗`, but the example sat under an `Inserting data` heading and the standalone page kept `input_format: true`. Both the embedded `system.formats.description` and the docs-site metadata thus suggested an `INSERT ... FORMAT JSONCompactStringsEachRowWithProgress` path that does not exist. Drop the misleading `Inserting data` heading in both the embedded documentation (in `JSONCompactEachRowWithProgressRowOutputFormat.cpp`) and the standalone page -- matching the sibling `JSONCompactEachRowWithProgress`, which has no such subsection -- and set `input_format: false` on the standalone page. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 6841/6843 (99.97%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 1 line(s) · Uncovered code |
The branch was 1106 commits behind master (merge base 2026-06-14) and CI was red only on known master-wide flakes; merging to refresh CI against current master. The merge is textually clean: master's touches to the shared format files are additive (the embedded-format-documentation refactor in #106181 adds an optional setDocumentation API without changing the registration signatures, plus the new output_format_always_write_decimal_point_in_float_and_decimal setting from #62614), and the native Arrow IPC code under ArrowIPC/ is untouched by master. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The branch was 1106 commits behind master (merge base 2026-06-14) and CI was red only on known master-wide flakes; merging to refresh CI against current master. The merge is textually clean: master's touches to the shared format files are additive (the embedded-format-documentation refactor in ClickHouse#106181 adds an optional setDocumentation API without changing the registration signatures, plus the new output_format_always_write_decimal_point_in_float_and_decimal setting from ClickHouse#62614), and the native Arrow IPC code under ArrowIPC/ is untouched by master. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Fourth PR in the series that adds embedded, runtime-introspectable documentation to ClickHouse component registries (after table engines #106177, database engines #106178, and data types #106180). This one does it for input/output formats.
What it does:
documentationfield toFormatFactory::Creators, aFormatFactory::setDocumentationmethod, and exposesdescription,examples,introduced_in, andrelatedcolumns onsystem.formats(formats have no meaningfulsyntax, so that column is omitted here).docs/en/interfaces/formats/into thedescriptionfield, so the standalone Markdown files can later be dropped and regenerated from the embedded documentation.TSV,TSVRaw,TSVWithNames…,Raw,RawWithNames…,JSONL,NDJSON,MD,PrettyJSONLines,PrettyNDJSON) get a concise description that references their canonical format viarelated.factory.setDocumentation(...)call is placed in theregister*Format*function of the corresponding source file undersrc/Processors/Formats/Impl/, right after the format registers. This co-locates the documentation with the format and naturally guards it with the same optional-library#ifconditions (USE_ARROW,USE_PROTOBUF, etc.).R"DOCS_MD( ... )DOCS_MD"raw-string literals. Rather than excluding whole files from the heuristic C++ style checks, the checks are made smarter: a helperci/jobs/scripts/check_style/filter_embedded_docs.pydrops style-check hits that fall inside those raw strings (literal tabs inTabSeparated/TSVexamples,Prettyresult tables indented by one to three spaces, trailing whitespace inherited from the Markdown pages), andcheck_whitespacesskips them directly.Note: this PR shares
src/Common/Documentation.h/.cppwith the earlier PRs in the series (trivial add/add on merge).Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Input/output formats now carry embedded documentation, introspectable via the new
description,examples,introduced_in, andrelatedcolumns of thesystem.formatstable.Documentation entry for user-facing changes
system.formatsand an updatedsystem.formatssystem-table page).Version info
26.6.1.796