Repository navigation
fix: pass return_columns to timeSeriesSelector on ClickHouse 26.11 - #3824
Conversation
ClickHouse 26.11 added a required return_columns argument to
timeSeriesSelector(). The 5-argument ('db', 'table', selector, min, max)
call is now read as (table, selector, min, max, return_columns), so 'db'
is taken as the table and every PromQL label lookup with match[] fails
with UNKNOWN_TABLE. 26.10 and earlier reject a sixth argument, so the call
form is picked by server version.
'samples' is passed because only `id` is read: it matches the bucketed
layout of version 11 tables, while 'timestamp_and_value' would unfold
every bucket with arrayJoin. On older layouts the unused column is pruned.
|
@bcanvural is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
PR Review
1 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 0 P3 1 posted as inline comment(s) on the changed lines. Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. This is a small, well-scoped version-gate fix; the query-construction change keeps user-controlled selectors as bound parameters and appends only a static literal, so no injection or correctness regression is introduced. The one substantive gap is test coverage of the new version→gate wiring. 🟡 P2 — recommended
🔵 P3 nitpicks (1)
Reviewers (9): correctness, testing, maintainability, project-standards, kieran-typescript, performance, security, agent-native, learnings-researcher. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
🦋 Changeset detectedLatest commit: 06aa579 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Added both tests in af1831e: the version check gets a boundary block like its neighbours, and the call form is checked on the generated SQL for both branches, so CI covers the 26.11 path without a 26.11 server. I left the P3 log out: an unknown version falls back the same way in every other version check. |
| 'match[] requires a TimeSeries table that stores time ranges (store_time_ranges = 1, or store_min_time_and_max_time = 1 before version 8), or the prometheus_api_v1 HTTP handler on ClickHouse 26.9+', | ||
| ); | ||
| } | ||
| const version = await metadata.getServerVersion({ connectionId }); |
There was a problem hiding this comment.
🟡 P2 — SELECT version() now runs on every match[] label lookup, after the time-bounds probes have finished
metadata is built on a throwaway new MetadataCache() (line 176), so getServerVersion sends a fresh SELECT version() on every call. It waits until timeSeriesTimeBounds has finished its one or two probe queries, which adds a third sequential round trip to every dashboard-variable lookup that uses match[]. When selectors != null, start metadata.getServerVersion({ connectionId }) alongside timeSeriesTimeBounds with Promise.all (it does not depend on the bounds), or pass in a version the caller already holds.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
Leaving this as is: it only runs when match[] is given, and SELECT version() is a sub-millisecond query next to the tags scan that follows. Running it in parallel is a fine follow-up if lookups ever show it.
|
Deep review P2 on the wiring: both halves are tested, and the one line joining them is type-checked (a missing Two review rounds are done with no P0/P1 left, so I'll stop on the automated findings here. @karl-power, could you take a look when you have time? This fixes the |
Summary
ClickHouse 26.11 added a required
return_columnsargument totimeSeriesSelector(). Our 5-argument call('db', 'table', selector, min, max)is now read as(table, selector, min, max, return_columns):'db'is taken as the table, and every PromQL label lookup withmatch[]fails withTable default.<db> does not exist. On a PromQL source with thetable-functionbackend, that breaks every dashboard variable dropdown. 26.10 and earlier reject a sixth argument, so the call form is now picked by server version.('db', 'table', q, min, max)UNKNOWN_TABLE('db', 'table', q, min, max, 'samples')requires 4..5 arguments'samples'is passed because onlyidis read. It matches the bucketed layout of version 11 tables, where'timestamp_and_value'would add anarrayJoinover every bucket. On older layouts the unusedsamplescolumn is pruned (checked withEXPLAIN header = 1on 26.11).Until this ships, a PromQL source can use the
clickhouse-httpbackend if the server has theprometheus_api_v1handler.Testing
timeseriesEngine.int.test.ts(47 tests) passes on 26.10.3.7 (the CI version) and on 26.11.1.2942. On 26.11 without this change, 19 of thematch[]tests fail.Closes #3825
Note
Medium Risk
Version-gated SQL for PromQL label filtering affects dashboard variables on 26.11+; wrong branching would break either new or old ClickHouse servers.
Overview
ClickHouse 26.11 makes the
return_columnsargument ontimeSeriesSelector()required, so the old 5-argument PromQLmatch[]SQL was mis-parsed and broke label lookups (e.g. dashboard variables).This PR adds
timeSeriesSelectorTakesReturnColumns()in common-utils and, when building series filter SQL in the timeseries engine, passes'samples'as the sixth argument only on 26.11+, while keeping the legacy 5-argument call on older servers. Unit tests cover the version gate and the generated SQL shape.Reviewed by Cursor Bugbot for commit 06aa579. Bugbot is set up for automated code reviews on this repo. Configure here.