fix(clickhouse): Fix ARRAY JOIN alias broken by ClickHouse v26 new analyzer#8547
Conversation
…alyzer In ClickHouse v26, `ARRAY JOIN events AS e` followed by `e.bool_attributes.key` fails with: code: 44, message: There is no subcolumn bool_attributes.key in type Tuple(name String) The new analyzer resolves the alias `e` to only `Tuple(name String)` instead of the full nested type. Fix by removing the alias and using the full column path (`events.*` / `links.*`) directly, which works in both v25 and v26. Agent-Logs-Url: https://github.com/jaegertracing/jaeger/sessions/42ffacdc-96db-477d-ba0c-1b83420103db Co-authored-by: yurishkuro <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR fixes ClickHouse v26 compatibility for the v2 ClickHouse schema materialized views that extract event/link attribute keys. It avoids ARRAY JOIN <nested> AS <alias> because ClickHouse v26’s new analyzer can infer an incomplete alias type for nested-in-nested columns, causing subcolumn lookups (e.g., bool_attributes.key) to fail.
Changes:
- Remove
AS e/AS laliases fromARRAY JOINoneventsandlinks. - Update all nested attribute key references to use full paths like
events.bool_attributes.keyandlinks.complex_attributes.key.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/storage/v2/clickhouse/sql/create_link_attribute_metadata_mv.sql | Drops links AS l alias and rewrites references to links.* subcolumns for ClickHouse v26 analyzer compatibility. |
| internal/storage/v2/clickhouse/sql/create_event_attribute_metadata_mv.sql | Drops events AS e alias and rewrites references to events.* subcolumns for ClickHouse v26 analyzer compatibility. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8547 +/- ##
==========================================
+ Coverage 96.53% 96.54% +0.01%
==========================================
Files 329 329
Lines 17342 17342
==========================================
+ Hits 16741 16743 +2
+ Misses 452 451 -1
+ Partials 149 148 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Root cause
The SPM ClickHouse e2e test (PR #8536) fails because ClickHouse v26's new analyzer changed how
ARRAY JOIN nested_col AS aliasresolves the alias type for nested-in-nested columns.From the docker logs:
In ClickHouse v26, after
ARRAY JOIN events AS e, the aliasegets typeTuple(name String)instead of the full nested type — so accessinge.bool_attributes.key(a sub-nested column) fails.Fix
Remove the
AS e/AS laliases from theARRAY JOINclauses and reference the nested sub-columns via their full paths (events.bool_attributes.key,links.bool_attributes.key, etc.) instead. This works in both ClickHouse v25 and v26.Before (
create_event_attribute_metadata_mv.sql):After:
Same change in
create_link_attribute_metadata_mv.sql(links AS l→links).