feat(core): support refreshable materialized views (NUM-6762)#110
Merged
alvarogar4 merged 2 commits intomainfrom Apr 20, 2026
Merged
Conversation
Add an optional `refresh` field to `materializedView()` covering all clauses
ClickHouse supports for refreshable MVs (GA since 24.10): EVERY/AFTER,
OFFSET, RANDOMIZE FOR, DEPENDS ON, SETTINGS, APPEND, and EMPTY.
The planner emits `ALTER TABLE ... MODIFY REFRESH ...` for schedule-only
changes and drop+recreate for structural ones. APPEND is treated as
structural because ClickHouse rejects toggling it via ALTER, and MODIFY
REFRESH always re-emits APPEND when present (the server rejects omitting
it on an existing APPEND MV).
Validator rejects combinations verified invalid against ClickHouse 25.12:
missing or both `every`/`after`, malformed intervals, `DEPENDS ON` paired
with `REFRESH AFTER`, and non-APPEND RMVs targeting `SharedMergeTree` /
`Replicated*` tables in the same schema.
`@chkit/plugin-pull` parses the REFRESH block out of
`system.tables.create_table_query`, strips Cloud-injected `DEFINER` / `SQL
SECURITY` clauses, and renders `refresh: { ... }` back into the generated
schema file.
Also converts `sql-validation.e2e.test.ts` from `test('setup'/'teardown')`
to `beforeAll/afterAll` so tests nested under the top-level `describe`
see an initialized client — pre-existing test-ordering bug.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
f72e0b0 to
d0bf7fe
Compare
Prevents ticket exports, research drafts, and other working notes from ever being tracked. Flagged in code review — Linear URLs, personal emails, and customer hostnames sometimes end up in these files. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
refreshfield tomaterializedView()covering all ClickHouse refreshable-MV clauses (EVERY/AFTER, OFFSET, RANDOMIZE FOR, DEPENDS ON, SETTINGS, APPEND, EMPTY). GA since ClickHouse 24.10.ALTER TABLE … MODIFY REFRESH …for schedule-only changes and drop+recreate for structural ones. APPEND is structural — the server rejects toggling it via ALTER, and MODIFY REFRESH always re-emits APPEND when set (verified live; undocumented).every/after, malformed intervals,DEPENDS ONwithREFRESH AFTER, and non-APPEND RMVs targeting replicated (SharedMergeTree/Replicated*) tables in the same schema.@chkit/plugin-pullparses the REFRESH block fromsystem.tables.create_table_query, strips Cloud-injectedDEFINER/SQL SECURITYnoise, and round-tripsrefresh: { … }into generated schema files.schema/refreshable-views.mdreference page;schema/dsl-reference.mdupdated with therefreshrow.sql-validation.e2e.test.tsfromtest('setup'/'teardown')tobeforeAll/afterAllso tests nested under the top-leveldescribesee an initialized client (pre-existing ordering bug — same fix as the danglingfc4d2c6commit).Test plan
bun verify(typecheck + lint + test + build via Doppler CI config — customer-chx) — 33/33 tasks, 419 tests pass, 0 fail@chkit/core(SQL rendering, diff rules, canonical, validation) and +7 in@chkit/plugin-pull(parser, DEFINER stripping, render)MODIFY REFRESH→ drop+recreate on query change → remove)chkit generate+migrate --applyflow for create/modify/dropNote on refresh execution: scheduled refreshes do not fire on customer-benchmark because of a cluster-side permission issue (
permission denied for table refresh_coordinationinsystem.view_refreshes.exception). chkit's DDL management is unaffected; worth filing a separate Numia infra ticket for the cluster.Closes NUM-6762.
🤖 Generated with Claude Code