Skip to content

Docs: document CREATE WORKLOAD, CREATE RESOURCE, CREATE INDEX and their DROP forms - #131653

Open
groeneai wants to merge 5 commits into
ClickHouse:masterfrom
groeneai:docs-workload-resource-index-statements
Open

groeneai wants to merge 5 commits into
ClickHouse:masterfrom
groeneai:docs-workload-resource-index-statements

Conversation

@groeneai

@groeneai groeneai commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #131085

Changelog category (leave one):

  • Documentation (changelog entry is not required)

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

Document the CREATE WORKLOAD, CREATE RESOURCE and standalone CREATE INDEX statements, and DROP WORKLOAD, DROP RESOURCE and DROP INDEX ... ON, in the SQL reference.

Description

One of the PRs for the statements without reference documentation that @ Blargian asked for in #131085. CREATE WORKLOAD and CREATE RESOURCE were described only in the workload scheduling guide; the standalone CREATE INDEX ... ON t / DROP INDEX ... ON t, DROP WORKLOAD and DROP RESOURCE had no reference text.

ParserCreateWorkloadQuery, ParserCreateResourceQuery and ParserCreateIndexQuery get a documentation entry each and are registered, so system.statements exposes them and the docs autogeneration fills the new create/workload.mdx, create/resource.mdx and create/skipping-index.mdx (frontmatter and empty markers, like #131085). The DROP entry gains DROP INDEX, DROP WORKLOAD and DROP RESOURCE sections; the CREATE overview lists the new forms and ALTER TABLE ... INDEX links them; the guide's "See also" links the two new pages.

Each page and section states the version it was introduced in, checked on the release tags: v22.7.0 for CREATE INDEX/DROP INDEX, v24.11.0 for the workload and resource statements, and per access mode v25.4.0 (MASTER THREAD, WORKER THREAD), v25.6.0 (QUERY), v26.6.2 (MEMORY RESERVATION). No statement is behind an experimental setting; the pages mark memory reservation scheduling experimental, as the guide does.

Validation: I checked every behaviour the pages describe on a server built from this branch (disk and Keeper workload storage, configuration-defined workloads, privileges), and the examples are copied from those runs. I regenerated the pages with autogenerate_docs.py --write --only 'statement:' and ran lychee_check.py --mode links (0 errors; a corrupted anchor is reported), navigation_check.py and check_autogenerated_regions.py; the committed tree contains no generated text. 04926_system_statements fails without the three new reference lines and passes with them.

🤖 Generated with Claude Code


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

groeneai and others added 2 commits November 14, 2026 15:21
…ir DROP forms

`CREATE WORKLOAD` and `CREATE RESOURCE` were documented only in the
workload scheduling guide, and the standalone `CREATE INDEX ... ON t`,
`DROP INDEX ... ON t`, `DROP WORKLOAD` and `DROP RESOURCE` had no
reference text, although the parsers accept them.

`ParserCreateWorkloadQuery`, `ParserCreateResourceQuery` and
`ParserCreateIndexQuery` get a documentation entry each and are
registered, so `system.statements` exposes them and the docs
autogeneration fills the new `create/workload.mdx`, `create/resource.mdx`
and `create/skipping-index.mdx` pages. The `DROP` entry gains `DROP INDEX`,
`DROP WORKLOAD` and `DROP RESOURCE` sections, the `CREATE` overview lists
the new forms, and `ALTER TABLE ... INDEX` links the standalone statements.

Each page and section states the version it was introduced in, measured
on the first release tag of each version through the GitHub API:
v22.7.0 for `CREATE INDEX`/`DROP INDEX`, v24.11.0 for the workload and
resource statements, and per access mode v25.4.0 (`MASTER THREAD`,
`WORKER THREAD`), v25.6.0 (`QUERY`) and v26.7.0 (`MEMORY RESERVATION`).
No statement is behind an experimental setting; the pages mark memory
reservation scheduling experimental, as the workload scheduling guide does.

Every behaviour on the pages was observed on a server built from this
branch, and the examples are copied from those runs. The generated
regions are left to the autogeneration workflow.

Related: ClickHouse#131085

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 31de00e.

Approve preview

@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (0 blocker, 0 major, 2 nits).

# Sev Finding Verdict Evidence / action
1 💡 CREATE RESOURCE points to CREATE WORKLOAD#syntax for ON CLUSTER, whose rule is under #storage AGREE noted, not changed: the resource page's own Storage section links #storage
2 💡 the new DROP examples drop objects created on the CREATE pages instead of creating them first AGREE noted, not changed

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-8:20261114-153001

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. 04926_system_statements with the old reference fails with exactly +CREATE INDEX, +CREATE RESOURCE, +CREATE WORKLOAD; autogenerate_docs.py --only 'statement:' without create/workload.mdx fails with registered statements have no matching Mintlify page title: CREATE WORKLOAD.
b Root cause explained? The reference pages are generated from getDocumentation() of the parsers registered in registerParsers.cpp. ParserCreateWorkloadQuery, ParserCreateResourceQuery and ParserCreateIndexQuery had none and were not registered, and documentation["DROP"] had no INDEX/WORKLOAD/RESOURCE section.
c Fix matches root cause? Yes: documentation entries in the parsers that parse these statements, plus registration. New pages carry only frontmatter and empty markers; no generated region is edited (check_autogenerated_regions.py OK).
d Test intent preserved / new tests added? 04926_system_statements reference lists the three new statements. 04927, 05043, 04408, 04409, 04357 (generic documentation shape) unchanged.
e Both directions demonstrated? 04926 fails with the old reference and passes with the new one; the generator fails without the new page and succeeds with it; lychee passes and reports a corrupted new anchor.
f Fix is general across code paths? Every form the parsers accept is documented and was run on a branch build: CREATE [OR REPLACE] WORKLOAD/RESOURCE [IF NOT EXISTS] [ON CLUSTER], all eight access modes, CREATE [UNIQUE] INDEX [IF NOT EXISTS] ... [ON CLUSTER], DROP INDEX/WORKLOAD/RESOURCE [IF EXISTS] [ON CLUSTER], disk and Keeper storage, configuration-defined entities.
g Fix generalizes across inputs (params/datatypes/wrappers)? Documented rules observed at their boundaries: empty access list, mixed kinds, a second MASTER THREAD/QUERY/MEMORY RESERVATION resource, cycles, unknown setting, FOR on a non-resource, a Memory table, UNIQUE and missing TYPE with both setting values.
h Backward compatible? (maintainer-approved exception only) Yes: documentation registrations only, no behaviour or setting change.
i Invariants and contracts preserved? Every registered statement has exactly one page (generator OK), every .parent/.related name is registered (04926), every link the PR adds resolves on the regenerated tree, every new page is in navigation.

Session id: cron:clickhouse-impl-slot-41:20261114-145700

@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [31de00e]

Summary: ✅


AI Review

Summary

Adds source-owned reference documentation for CREATE WORKLOAD, CREATE RESOURCE, standalone CREATE INDEX, and their DROP forms, with parser registrations and navigation entries. No unresolved findings remain. The previous Keeper deletion privilege issue is fixed by PR #131688, and the PR's Fast test report confirms that 04926_system_statements passes.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-documentation Documentation PRs for the specific code PR can be tested Allows running workflows for external contributors comp-documentation Documentation (docs, examples, READMEs). labels Nov 14, 2026
Comment thread src/Parsers/ParserDropQuery.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 31de00ef0 with master f5c31fd2b (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

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

9 object files changed (+60.33 KiB total), 0 added.

Object file Master PR Δ
src/Parsers/CMakeFiles/clickhouse_parsers.dir/ParserCreateWorkloadQuery.cpp.o 81.49 KiB 102.14 KiB +20.66 KiB (+25.35%)
src/Parsers/CMakeFiles/clickhouse_parsers.dir/ParserCreateResourceQuery.cpp.o 68.97 KiB 87.55 KiB +18.59 KiB (+26.95%)
src/Parsers/CMakeFiles/clickhouse_parsers.dir/ParserCreateIndexQuery.cpp.o 64.30 KiB 82.71 KiB +18.42 KiB (+28.65%)

716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

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

Job report

@serxa serxa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good. Storage aspects are not covered though. But can be improved separately.

@serxa

serxa commented Nov 14, 2026

Copy link
Copy Markdown
Member

@groeneai tag me when it's ready to be merged

@groeneai

Copy link
Copy Markdown
Collaborator Author

CI has finished: everything is green except Mergeable Check, which fails only on the review-threads gate for the AI review's thread.

That blocker is real but predates this PR: with workload_zookeeper_path set, a user granted only DROP WORKLOAD can delete a resource with DROP WORKLOAD <name>, and DROP RESOURCE <name> deletes a workload the same way, because WorkloadEntityStorageBase::removeEntity matches the name without checking the entity type. I reproduced both directions on this branch's build; disk storage is not affected. I'm fixing it in a separate PR, so from my side this PR is ready to merge.

groeneai and others added 2 commits November 16, 2026 01:58
ClickHouse#126158 enabled clang-tidy `modernize-use-nodiscard` on master, so the
three `getDocumentation` declarations this PR adds to
ParserCreateIndexQuery, ParserCreateResourceQuery and
ParserCreateWorkloadQuery would fail `Build (arm_tidy)` on the merge
commit, as `ParserTransactionControl.h:12` already does on master.
Same form as `ParserDropQuery::getDocumentation` there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClickHouse#82414 was backported to 26.6 (ClickHouse#108687) and is listed in the 26.6
changelog: the parser accepts `MEMORY RESERVATION` in v26.6.2.81-stable
but not in v26.6.1.1193-stable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pushed 375f67d after #126158 enabled modernize-use-nodiscard on master: [[nodiscard]] on the three new getDocumentation declarations, and the MEMORY RESERVATION row now says v26.6.2, since #82414 was backported to 26.6 (#108687). Nothing else changed.

eoger-ant pushed a commit to eoger-ant/ClickHouse that referenced this pull request Nov 16, 2026
…r kind

Workloads and resources share one name space in
`WorkloadEntityStorageBase::entities`, and `removeEntity` looked the name up
without checking that the stored entity is of the requested kind. With Keeper
workload storage (`workload_zookeeper_path`), `removeEntityImpl` rewrites the
single znode without that name, so `DROP WORKLOAD cpu` removed the resource
`cpu` and `DROP RESOURCE x` removed the workload `x`. The interpreters only
check the privilege of the statement's own kind, so a user granted only
`DROP WORKLOAD` could remove resources and vice versa.

Disk storage was safe only because its file name is kind-specific
(`workload_<name>.sql` / `resource_<name>.sql`), so the same statement failed
with "Workload entity 'cpu' doesn't exist". Treat an entity of the other kind
as missing in the base class, which every storage goes through: the statement
now fails the same way on every storage, and `IF EXISTS` is a no-op. The check
sits inside the retry loop, so it is re-done after a Keeper version conflict.

The sibling write path `storeEntity` already rejects a kind mismatch for
`CREATE OR REPLACE`.

Reported by the AI review on ClickHouse#131653
(ClickHouse#131653 (comment)).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@serxa

serxa commented Nov 19, 2026

Copy link
Copy Markdown
Member

@groeneai build is still broken, take care

The previous run (375f67d) failed Build (arm_tidy) only on master's
src/Parsers/ParserTransactionControl.h:12, fixed on master by ClickHouse#131891.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

The red Build (arm_tidy) jobs failed only on master's src/Parsers/ParserTransactionControl.h:12 (getDocumentation without [[nodiscard]]), which #131891 fixed on master after this PR's last run; the headers this PR adds pass. I pushed an empty commit (31de00e) so CI rebuilds on current master.

The open AI review thread is about the Keeper DROP issue that #131688 fixed (merged), so the bot should resolve it on this run; until then Mergeable Check stays red on review threads only.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-documentation Documentation (docs, examples, READMEs). pr-documentation Documentation PRs for the specific code PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants