Repository navigation
Conversation
|
Workflow [PR], commit [63940ef] Summary: ❌
|
|
|
||
| auto join = make_intrusive<ASTTableJoin>(); | ||
| join->kind = JoinKind::Left; | ||
| join->strictness = JoinStrictness::Semi; |
There was a problem hiding this comment.
This generated query selects time_series from the right subquery, but SEMI LEFT JOIN only preserves the left-side columns and uses the right side only as an existence filter. For a query like SELECT metric_name, time_series FROM prometheus, the plan either cannot resolve time_series from __samples_grouped, or it drops series that have a tags row but no samples row. Please use a normal left join against the grouped samples subquery and materialize an empty time_series value for missing matches.
|
|
||
| auto samples_table_id = storage.getTargetTableID(ViewTarget::Samples, context); | ||
| if (!need_tags) | ||
| return makeBareSamplesSelect(samples_table_id); |
There was a problem hiding this comment.
Driving the time_series-only path from samples changes the TimeSeries row contract. TimeSeriesSink writes a tags row even when the inserted time_series array is empty, but it writes no samples rows in that case, so SELECT time_series FROM prometheus will omit those series entirely. The read path should still drive from tags and left-join the grouped samples, even when no tag columns are requested.
| /// the samples-side branches. | ||
| ASTPtr makeTimeSeriesAggregate() | ||
| { | ||
| auto group_array = makeASTFunction("groupArray", |
There was a problem hiding this comment.
groupArray(tuple(timestamp, value)) does not preserve the time-series aggregate semantics used elsewhere in this subsystem. Once the samples table is read in multiple blocks or after merges, the array order is not guaranteed, and duplicate timestamps are not normalized the way timeSeriesGroupArray does. Please build time_series with timeSeriesGroupArray(timestamp, value) or otherwise enforce the same timestamp ordering and duplicate handling.
| { | ||
| String pattern = matcher.label_value; | ||
| if (!pattern.starts_with('^')) | ||
| pattern.insert(0, "^"); |
There was a problem hiding this comment.
PromQL regex matchers are anchored as a whole expression, but adding ^ and $ directly changes the meaning of patterns with alternation. For example, {job=~"api|web"} should match only api or web, while this compiles to ^api|web$, which also matches values like api-v1 and db-web. Wrap the original regex when anchoring, for example ^(?:<regex>)$, and add a test with an alternation matcher.
… 1.0 Replace the flat per-sample schema (name, value, labels, timestamp, ...) with a per-series schema aligned to the TimeSeries engine's own columns: metric_name, metric_family, help, type, unit, tags Array(Tuple(String, String)), and time_series Array(Tuple(DateTime64(3), Float64)). One row is one series and its points live in the time_series array. The output format groups rows by metric_family, emits # HELP/# TYPE/# UNIT once per family, and conforms to OpenMetrics 1.0: the version=1.0.0 content type, the type vocabulary (untyped -> unknown), the counter _total sample contract, and the unit suffix rule. The input format buffers to # EOF, groups samples by (metric_name, tags) into a time_series array, and derives metric_family from declared families and the sample-name suffix rules. The time_series value type is required to be Float64 on both input and output, matching the engine column. Rewrites the stateless 04003 test and the Prometheus/OpenMetrics export integration test for the new schema; the SELECT * FROM ts round-trip is staged but skipped pending ClickHouse#106010.
3110fe6 to
eb9ce7f
Compare
42b1f6f to
28877fe
Compare
Move the `StorageTimeSeries` check into `storage_requires_filter_collection`, which the `StorageMerge` branch also uses via `hasChildTable`. Now filter collection triggers not only when a TimeSeries table is queried directly, but also when it is read through a `Merge` table, so a `WHERE` above the `Merge` is captured and forwarded down to the TimeSeries inner table reads.
28877fe to
63940ef
Compare
|
I'll split the work to a couple of PRs: |
|
Dear @vitlibar, this PR hasn't been updated for a while. Will you continue working on it? If not, please close it. Otherwise, ignore this message. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Implement
SELECTfrom TimeSeriesWorkflow [PR]
Sync PR [sync-upstream/pr/106010]