feat: Allow INDEX syntax sugar for projections with _part_offset - #651
feat: Allow INDEX syntax sugar for projections with _part_offset#65129antonioac wants to merge 11 commits into
INDEX syntax sugar for projections with _part_offset#651Conversation
5a783bd to
32c0d34
Compare
…version it in our CI so its harder to maintain
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit bc00721. Configure here.
| {%- if not adapter.is_before_version('26.1.1.1') -%} | ||
| PROJECTION {{ proj_name }} INDEX {{ cols_index_expr }} TYPE basic | ||
| {%- else -%} | ||
| PROJECTION {{ proj_name }} (SELECT _part_offset ORDER BY {{ cols_str }}) |
There was a problem hiding this comment.
Missing ClickHouse 25.6 guard
High Severity
A refactor removed the compile-time check that prevented index projections from being used on ClickHouse versions before 25.6. Now, dbt emits _part_offset-based projection DDL for these older versions, which results in a runtime ClickHouse error. This failure happens later in the run, potentially after distributed materializations have already dropped tables.
Reviewed by Cursor Bugbot for commit bc00721. Configure here.
There was a problem hiding this comment.
Not needed, version not supported.
|
Hi @29antonioac , I did a few changes to the PR, can you do a second check of them?
|


Summary
indexparameter toprojectionsmodel config to allow setting index projections nicer.ADD PROJECTION my_projection INDEX my, columns TYPE basicif ClickHouse 26.1+ADD PROJECTION my_projection (SELECT _part_offset ORDER BY my, columns)if ClickHouse 25.6+INDEXsyntax to add projections with_part_offsetfrom 26.1 #650Checklist
Delete items not relevant to your PR:
INDEXprojections clickhouse-docs#6546Note
Low Risk
Scoped to projection DDL generation in table materialization with backward-compatible
querybehavior and compile-time guards; main risk is wrong version-specific SQL on edge ClickHouse versions.Overview
Adds an optional
indexfield on each entry in theprojectionsmodel config so you can declare lightweight index projections without writing rawADD PROJECTIONSQL. Theadd_index_and_projectionsmacro still emitsADD PROJECTION … (query)whenqueryis set; withindexonly, it builds version-specific DDL:INDEX … TYPE basicon ClickHouse 26.1+, or(SELECT _part_offset ORDER BY …)on 25.6–26.0. Compile-time errors blockquery+index, missing both, orindexon servers before 25.6. The 1.10.1 changelog documents the feature; integration tests cover happy paths, validation messages, and version gating (existing projection tests were reformatted).Reviewed by Cursor Bugbot for commit 06962eb. Bugbot is set up for automated code reviews on this repo. Configure here.