Repository navigation
fix(schema-compiler): Keep boolean dimensions and segments boolean in ClickHouse pre-aggregations - #12598
fix(schema-compiler): Keep boolean dimensions and segments boolean in ClickHouse pre-aggregations#12598waralexrom wants to merge 5 commits into
Conversation
|
Claude finished @waralexrom's task in 3m 17s —— View job Review: the fix works, but the Details
Findings
Notes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12598 +/- ##
===========================================
+ Coverage 66.18% 83.16% +16.98%
===========================================
Files 258 531 +273
Lines 21978 124737 +102759
Branches 5290 5291 +1
===========================================
+ Hits 14546 103738 +89192
- Misses 6636 20203 +13567
Partials 796 796
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Claude finished @waralexrom's task in 2m 27s —— View job Review: 1 medium issue still open from the last round, plus 1 low note. No new inline comments. Details
FindingsMedium (re-affirmed, open thread on
Low: the PR description is stale. It still mentions Checked and fine
Review threadsThe listing returned 2 of my own unresolved threads. I resolved 1: |
|
Claude finished @waralexrom's task in 2m 33s —— View job Changes requested: 2 medium. 1 new inline finding, 1 earlier thread still applies. Review details
FindingsMedium:
A Medium: #9494 isn't fixed under the legacy planner, and the segment test doesn't show it (
Other notes
Review threadsThe listing returned 1 of my own unresolved threads. I resolved 0 and re-affirmed 1 ( |
|
Claude finished @waralexrom's task in 3m 48s —— View job Review: 1 high (missing docs), 1 low (comment wording), 1 earlier finding still open. No correctness bugs found in either planner. Details
Findings
Checked, no issue
Review threads2 of my threads were open.
Both new findings were posted as new threads; neither duplicates an earlier one. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
… ClickHouse pre-aggregations ClickHouse predicates evaluate to UInt8, so a boolean dimension or a segment was built into a pre-aggregation as an integer column. Querying such a rollup in Cube Store with the segment failed with "Filter predicate must return boolean values, not Int64", and boolean dimensions read back as 0/1. Boolean dimensions and segments projected as dimensions are now wrapped in toBool() under both planners, so the source and the rollup return booleans. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ction only A toBool() wrap in a filter keeps ClickHouse from pruning by a boolean key column, so the wrap moves from every reference of the dimension to its SELECT projection in both planners. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nchanged The toBool() wrap of boolean dimensions and segments now applies under Tesseract only; the legacy planner renders them as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… wrap This reverts commit a3cbaf0: both planners keep boolean dimensions and segments boolean in ClickHouse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also fixes the wording of the projection-only wrap comment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a88b0c8 to
c42a77e
Compare
|
Claude finished @waralexrom's task in 1m 22s —— View job Review: approve-ready. 0 high, 0 medium, 0 low. All 3 earlier threads are resolved. Details
What changed since the last round
Checked, no issue
Review threadsThe listing returned 3 of my own threads. I resolved all 3 and re-affirmed none:
I posted no new inline comments. |
What was broken
ClickHouse comparison operators return
UInt8, notBool. The pre-aggregation load SQL selected boolean dimensions and segments as the bare expression (e.g.(`metrics`.brand_id = 17390) `metrics__curr_brand`), so the driver reported the column as an integer and the rollup was built with an integer column. Querying that rollup in Cube Store with the segment then failed withFilter predicate must return boolean values, not Int64, and boolean dimensions came back as0/1— from the source as well as from the rollup.Fix
SELECTprojection intoBool(...), so the column isBool(Nullable(Bool)stays nullable) and the driver maps it toboolean. This applies to both planners.wrapBooleanDimension, applied inBaseDimension.dimensionSql()(legacy planner), and theexpressions.wrap_boolean_dimensiontemplate, applied to projected boolean dimensions inAliasedExpr(Tesseract). Both default to the expression unchanged, so other dialects are untouched. A rollup read from Cube Store renders with Cube Store templates, where the wrap is a no-op; a rollup read inside ClickHouse already has aBoolcolumn, sotoBoolleaves it as it is.wrapSegmentForDimensionSelect/wrap_segment_selecthooks.Behavior change
A boolean dimension over a
Stringcolumn now has to hold values ClickHouse can parse as booleans (true/false,1/0,yes/no,on/off, ...). An empty or arbitrary string makes the query fail withCANNOT_PARSE_BOOLinstead of returning the raw string.accurateCastOrNull(..., 'Bool')would avoid the error, but it always yieldsNullable(Bool), and ClickHouse rejects a nullable column in the sorting key of a pre-aggregation built inside ClickHouse.Tests
test/integration/clickhouse/clickhouse-boolean-pre-aggregations.test.tsruns against ClickHouse in Docker under both Tesseract and the legacy planner. It compares the same query served from the source and from the rollup (booleans in both), checks a segment filter on the rollup, and checks that the rollup's column types areBool. On master the rollup columns areUInt8and the values come back as"1"/"0". It also checks withEXPLAIN indexes = 1that a filter on a boolean key column still uses the primary key.ClickHouseDbRunnercan now build pre-aggregations: it creates them as temporary tables and sends DDL throughcommand().Bool/Nullable(Bool)map to thebooleangeneric type.cargo test -p cubesqlplanner --libpasses.Fixes #9494
🤖 Generated with Claude Code