Skip to content

CI: autogenerate SQL statement documentation - #115609

Merged
Blargian merged 17 commits into
ClickHouse:masterfrom
Blargian:codex/statement-docs-autogen
Aug 25, 2026
Merged

Blargian merged 17 commits into
ClickHouse:masterfrom
Blargian:codex/statement-docs-autogen

Conversation

@Blargian

@Blargian Blargian commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

Extends the nightly documentation autogeneration job to regenerate every marked SQL statement page from source-owned documentation.

The generator enumerates every registered statement in one query, reads the complete rendered Markdown from system.documentation, and matches its unique registry name one-to-one with the corresponding Mintlify frontmatter title. All marked statement pages use that canonical registered name as their title. Missing pages, missing markers, duplicate names, stale marked pages, and empty rendered documents all fail closed.

This removes the checked-in page-to-statement manifest as well as presentation-only title metadata from the server source. A newly registered statement is automatically included in the generated inventory; its registry name and marked page form the routing contract. Using system.documentation also preserves structured sections such as syntax and related when they are not already part of the source-owned description.

The nightly generator has one supported output path: the current Mintlify documentation. It always resolves generated destinations through the current route map and normalizes source-formatted Markdown before writing. The legacy --no-remap-legacy mode and HTML region-marker compatibility have been removed.

The generator was run and all 99 statement pages pass the drift check. Structured Syntax, Part of, and Related sections are rendered when absent, while syntax already embedded in a source description is not appended a second time; this removes duplicate syntax blocks from 16 pages. The output also normalizes the 74 page titles that previously differed from their registered statement names; the other 25 titles already matched.

Builds on the source migration merged in #115608.

Related: #115341
Related: #115608

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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


Workflow [PR]
Sync PR [sync-upstream/pr/115609]

Version info

  • Merged into: 26.9.1.107 (included in 26.9 and later)

@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ebd0260]

Summary: ✅


AI Review

Summary

This PR moves SQL statement page generation onto system.documentation / system.statements, removes the checked-in statement manifest, and regenerates the statement pages from source-owned documentation. The fail-closed routing work looks solid overall, but the new related-section suppression is too broad: generic See Also / Related content blocks are now treated as if they were the source-owned statement cross-reference section, so structured statement links disappear from system.documentation and from the regenerated pages.

Findings

⚠️ Majors

  • [src/Storages/System/StorageSystemDocumentation.cpp:230-233] descriptionDocumentsRelated treats any See Also / Related content heading as if the source page already owns the statement cross-reference block. That drops structured related links on pages where those manual sections point somewhere else. UNION is a concrete repro: ParserSelectWithUnionQuery.cpp defines .related = {"SELECT", "INTERSECT", "EXCEPT", "DISTINCT", "JOIN"}, but the source description's **See Also** block only links insert_null_as_default and union_default_mode, so the regenerated docs/reference/statements/select/union.mdx and system.documentation lose all of those statement links. The new tests/queries/0_stateless/05043_statement_documentation_related_sections.sql check then locks in that weaker contract by asserting UNION has zero synthetic **Related:** blocks.
    Suggested fix: only suppress synthetic **Related:** when the description already has a true statement-related section (Related, Related statements, etc.), or merge the structured statement links into generic See Also / Related content sections instead of dropping them.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions:

  • Narrow the related-section suppression so generic See Also / Related content blocks do not discard structured statement cross-links.
  • Update the new regression query so pages like UNION still retain their structured statement links when the source description only has generic cross-references.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Aug 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing ebd0260fa with master 86a433ccd (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 710.09 MiB 707.05 MiB -3.04 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

8 translation units recompiled, 16 s compile time in total, 8 of them have a recent master baseline.

Job report

# Conflicts:
#	ci/jobs/docs_autogen_nightly.py
#	ci/jobs/scripts/docs/autogenerate/autogenerate_docs.py
#	ci/jobs/scripts/docs/autogenerate/test_no_remap_guard.py
@Blargian
Blargian marked this pull request as ready for review August 24, 2026 11:26
Use the normal `system.documentation` renderer so structured fields such as `syntax` remain part of short statement documents.

Related: ClickHouse#115609 (comment)
Enumerate all statements through `system.statements`, read rendered Markdown from `system.documentation`, and match it strictly to marked page titles.

Related: ClickHouse#115609 (comment)

Related: ClickHouse#115609 (comment)
@Blargian Blargian added the pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard label Aug 25, 2026
Keep the existing positional schema of `system.statements` stable by adding `title` after all established columns. Pin the column order in the stateless test.

Review: ClickHouse#115609 (comment)

PR: ClickHouse#115609
Fail closed when an autogenerated statement page has missing or invalid frontmatter `title` metadata, and cover that routing-contract error in the focused generator test.

Review: ClickHouse#115609 (comment)

PR: ClickHouse#115609
Use one Mintlify output pipeline and normalize source-formatted Markdown unconditionally. Remove the `--no-remap-legacy` option, its guard test, and compatibility with legacy HTML region markers.

Related: ClickHouse#115609
Make each marked page title match its unique `registerStatement` name. Remove the redundant `Documentation::title` field, `.title` registrations, and the unmerged `system.statements.title` column, then route generator output directly by name.

Related: ClickHouse#115609
Do not append a structured `Syntax` block in `system.documentation` when the source description already contains the same syntax. Regenerate the eight affected statement pages and add a functional regression check.

Related: ClickHouse#115609
Recognize explicit Markdown syntax labels and prose which directly
introduces an SQL syntax block. This avoids appending structured syntax
when punctuation or formatting differs from the source-owned section.

Regenerate the statement pages and cover the non-verbatim cases in the
`system.documentation` stateless test.

Related: ClickHouse#115609
@Blargian
Blargian enabled auto-merge August 25, 2026 16:33
Comment on lines +230 to +233
return equalsCaseInsensitive(line, "related")
|| equalsCaseInsensitive(line, "related content")
|| equalsCaseInsensitive(line, "related statements")
|| equalsCaseInsensitive(line, "see also");

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.

descriptionDocumentsRelated is currently treating any Related content / See Also heading as if the source page already owns the statement cross-reference block. That drops structured related links on pages where those manual sections point somewhere else.

UNION is a concrete repro: ParserSelectWithUnionQuery.cpp defines .related = {"SELECT", "INTERSECT", "EXCEPT", "DISTINCT", "JOIN"}, but the source description's **See Also** block only links insert_null_as_default and union_default_mode. With this heuristic, system.documentation and the regenerated docs/reference/statements/select/union.mdx lose all of those statement links. The same pattern also hits other statements that only have blog/settings See Also or Related content sections.

Can we narrow this suppression to true statement-related sections (Related, Related statements, etc.), or merge the structured statement links into generic See Also / Related content blocks instead of dropping them? The new 05043_statement_documentation_related_sections.sql check currently pins the weaker behavior by expecting UNION to stay at zero **Related:** blocks.

@Blargian
Blargian added this pull request to the merge queue Aug 25, 2026
Merged via the queue into ClickHouse:master with commit 4b2ab48 Aug 25, 2026
351 of 352 checks passed
@Blargian
Blargian deleted the codex/statement-docs-autogen branch August 25, 2026 20:04
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 25, 2026
Blargian added a commit to Blargian/ClickHouse that referenced this pull request Aug 26, 2026
Register `CREATE HANDLER` in `StatementFactory`, keep the full reference body in the parser registration, and mark the Mintlify page as generated through `system.documentation`.

Related: ClickHouse#115609

Related: ClickHouse#106231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard pr-ci 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