mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-12-04 00:15:29 +00:00
c878342db496fc0995dd32363f7d4fe1bc4e7dc2
1073
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6ccf4d9341 |
fix(meta): honor user providers for admin endpoints (#10774)
* fix(meta): honor user providers for admin endpoints Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(meta): authorize admin operations through permission checker Signed-off-by: WenyXu <wenymedia@gmail.com> * test(meta): cover admin HTTP authentication from configuration Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(meta): enforce admin authorization on matched plugin routes Signed-off-by: WenyXu <wenymedia@gmail.com> * fix: reject unregistered metasrv user providers Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: WenyXu <wenymedia@gmail.com> |
||
|
|
464ccc3abd |
fix(postgres): account CSV and JSONL COPY memory (#10493)
* feat(postgres): Prometheus Remote Write protobuf ingest via COPY FROM STDIN COPY FROM STDIN WITH (FORMAT promwrite [, version 2] [, <options>]) ingests one Prometheus Remote Write request body over the postgres wire protocol — a GreptimeDB-specific, binary COPY format (wire format code 1). The payload is byte-for-byte the body a remote-write client POSTs to /v1/prometheus/write, compression included: buffered until CopyDone and completed through the exact ingestion core that endpoint runs. To share that core, the HTTP handlers' ingestion bodies are extracted into axum-free functions (ingest_remote_write_v1/v2 plus the context extension stamping), and the HTTP routes become thin wrappers — their behavior is unchanged, and the copy layer runs the identical decode, validation, conversion, batched/prepared write paths, per-batch write-progress accounting and context extensions, under the connection's regular postgres context. The WITH options carry what the HTTP endpoint takes as its content-type/-encoding and query parameters; session-provided values (database, user) are not repeated: - version 1|2 (default 1), matching the content-type's proto - zstd, matching Content-Encoding: zstd (snappy by default) - physical_table, matching the ?physical_table= parameter - pipeline_name/pipeline_version, matching the pipeline headers (v1 only; for v2 they are accepted and ignored, exactly like the HTTP route ignores them) Table-less like the other ingestion formats; one COPY statement is one bounded request (shared 64 MiB limit); the row count reports written rows (v1) or written samples plus histograms (v2). The flush enforces the frontend's shared request-memory quota (max_in_flight_write_bytes) — the same limiter the HTTP ingestion protocols use, so COPY cannot bypass the aggregate budget. Wiring: PostgresServer::with_prom_remote_write carries the handler, metric-engine flag, validation mode and shared memory limiter. e2e: v1 body chunked across CopyData boundaries; v2 samples with readback; physical_table option routing; garbage-body decode failure with connection reuse; a tiny-quota regression where a compressed body whose decompressed size exceeds the budget fails like the HTTP route. Signed-off-by: Ning Sun <sunning@greptime.com> * feat(postgres): jsonl COPY FROM STDIN via the arrow-json engine COPY tbl [(cols)] FROM STDIN WITH (FORMAT jsonl) ingests newline-delimited JSON objects through arrow-json's incremental Decoder — the same engine behind file-based COPY ... FROM 'file.json' — so both COPY routes accept identical data. One JSON object per record; keys address the targeted columns by name, absent keys become NULL, and offset-free timestamp strings parse in the session timezone (the same schema substitution the csv codec makes), like SQL INSERT. The streaming contract mirrors arrow-csv's exactly (decode returns consumed bytes; a short read means a full batch), so the parser is a twin of the csv one: objects may span CopyData chunk boundaries, records surface in COPY_IN_FLUSH_ROWS batches, and a trailing object without its newline is accepted. Table-bound like csv (a named table is required; the column list fixes the target order); no options (the file format's layout options are writer-side; the reader parses date-times natively). The two table-bound codecs share the table path through a small TableBoundCodec trait (check_column_type + create_parser); csv's behavior is unchanged. e2e: chunked object-boundary ingest with absent-key NULLs; session-timezone parity against SQL INSERT; malformed JSON failure with table-left-clean and connection recovery. Signed-off-by: Ning Sun <sunning@greptime.com> * fix(postgres): account CSV and JSONL COPY memory Signed-off-by: Ning Sun <sunning@greptime.com> * fix(postgres): keep table COPY progressing within its memory quota Signed-off-by: Ning Sun <sunning@greptime.com> * fix(servers): preserve COPY headroom across admissions and batch boundaries Signed-off-by: Ning Sun <sunning@greptime.com> * fix(servers): admit first streamed body frame without counting wait probes Signed-off-by: Ning Sun <sunning@greptime.com> --------- Signed-off-by: Ning Sun <sunning@greptime.com> |
||
|
|
10b6cf9477 |
feat(query): add windowed PromQL evaluation (#10797)
* feat(query): add windowed PromQL evaluation Signed-off-by: discord9 <discord9@163.com> * docs(query): clarify window allowlist and drop unused grid bound The public end_ms_exclusive duplicated point_ms(points) without a caller. max_input_range_ms stays public for the stacked sequence-probe cache. Signed-off-by: discord9 <discord9@163.com> * refactor(query): trim window docs and merge overlapping allowlist tests Apply review: state the allowlist in a few lines instead of arguing for it, drop doc that restates the code or another item's doc, and make max_input_range_ms private since nothing outside window.rs calls it. Collapse the allowlist tests into one positive table that asserts the source table and the input range per row, and one negative table that asserts NotEligible once per shape. The grid tests keep the point_ms(points) continuation the frontend cache relies on and gain the negative-start phase case. The differential test drops asserts implied by full == merged and the SumRate arm that re-derived the aggregate. Signed-off-by: discord9 <discord9@163.com> * docs(query): shorten window docs and cover sum(selector) in the differential Apply review: state the grid rule and the caller's duty in a few lines, point the selector helper at windowed_source_table instead of repeating its reasoning, and drop the doc that restates the GridSpec bound. Add sum(window_diff) as a fourth differential shape so the aggregate the allowlist admits over a bare selector is compared on both routes too. Make max_input_range_ms public again: the sequence-probe cache reads the input range to bound what a chunk depends on, and WindowGrid::of alone does not expose it. Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> |
||
|
|
8ea60a155c |
fix(promql): keep NULL rows of native instant selectors (#10762)
* fix(promql): keep NULL rows of native instant selectors A selector at the statement root dropped a selected row whose fields are all NULL, so native TQL answered nothing where the existing planner answers a NULL row, and an all-NULL series disappeared. The root selection now reports stored rows (InstantValue::Row); selections that feed functions, aggregations and binary operands keep dropping them. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * style: format the merge and document root selection precedence Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
4d44909217 |
feat(promql): read sub-millisecond file-engine time indexes natively (#10703)
* feat(promql): read second, microsecond and nanosecond time indexes natively The native route declined every selector over a time index that is not in milliseconds. The existing plan wraps such a scan in a cast projection, so the decline surfaced as selector_plan_is_not_a_table_scan, and the region's raw series preflight refused the unit as well. The raw series path now hands ticks over in the stored unit, and each raw input of the native tree records that unit. Evaluation keeps the existing plan's semantics: windows and lookbacks are decided on the stored ticks, a kernel reads the time truncated toward zero to milliseconds after the offset, and samples less than a millisecond apart remain distinct samples. Since every bound is a whole millisecond, deciding membership on ceil(tick) in milliseconds is exact, so the evaluators keep a window time beside the payload only for microsecond and nanosecond inputs. Scan filters are built in the stored unit. Histogram fields and range modifiers over a sub-millisecond time index still decline. The append-mode decline is kept and renamed to append_mode_table. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): decline a discovered selector over mixed time index units Logical metrics on different physical tables can store their time index in different units, while the union a nameless selector reads is one native input bound to one unit. The union took the first source's unit and read the other sources' ticks in it, so a series stored in microseconds next to one in milliseconds dropped out of its windows. Such a selector now declines. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): run native PromQL over file-engine tables File-engine tables have no raw series scanner, so the native route declined them and they fell back to the legacy planner. Read such a table through a new RowSeriesSource node: an ordinary scan, filtered by the selector's matchers and time range, hash-partitioned by tags and sorted by (tags, time index, fields), then cut into explicit-label raw series chunks with Float64 values. The node declares its input distribution and ordering, so the physical optimizer inserts the repartition and a spillable SortExec. It stays above the merge scan, so it runs on the frontend in both standalone and distributed mode. Rows sharing labels and a timestamp keep one sample, as Prometheus storage does: the row whose field values sort lowest (nulls last). Non-string tags and histogram fields keep the existing plan. The cluster test builder can now pass the local file sandbox to datanodes and install frontend-only plugins, so the distributed case is covered. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): read file-engine tags as Prometheus label values A row source now reads every tag column as text with NULL read as '', so a NULL and an empty tag are one series from the start and an empty value carries no label, as in Prometheus. Rows of that series at one timestamp keep one sample by the existing rule. Matchers apply to the text form above the scan, so an integer tag matches "200" but not "0200". This drops the row_source_tag_is_not_a_string decline. The legacy planner fails on such a table with "Unsupported tag column type: Int64". Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): read native histogram fields from file-engine tables A row source passes a native histogram field on as histogram samples, converted with the same histogram_samples_from_arrow the mito raw scan uses, instead of casting every field to Float64. This drops the row_source_reads_floats_only decline, so the fixture of the sqlness case promql/delta_exponential_histogram runs natively; the integration test mirrors its statements and answers. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): read second-precision file-engine time indexes natively The existing scan plan already promotes a second-precision time index to milliseconds through a projection, which is exact. A row source now reads that projection instead of declining, and pushes the time range into the scan only when the scan's time index is in milliseconds. Microsecond and nanosecond time indexes still keep the existing plan. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): decline file-engine tables with a `__name__` tag column A row source dropped a tag column named `__name__` from its labels, sort key and partition key, so rows that differed only in that column merged into one series and lost samples. Mito's raw scan refuses such a tag. Decline it at planning time instead, and make RowSeriesSource reject the tag rather than filter it out. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): dedupe file-engine samples per field A row source reduced rows sharing labels and a timestamp to one whole row picked by the first field, so a NULL in another field of that row dropped the value a discarded row held there. Each field is its own value series: at a duplicated timestamp every field now keeps its own lowest non-null value (NaN above numbers, histograms by struct order). The sort key drops the fields, and the rows of the last timestamp of a batch are held back until the next batch, so every duplicated timestamp is reduced within one batch. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): read microsecond and nanosecond file-engine time indexes natively A row source read its time index through the existing plan's cast to milliseconds, which truncates a finer one, so it declined microsecond and nanosecond time indexes. It now reads the column as stored, as the raw series scan does, and the input it feeds is bound to the time index's unit. Evaluation then follows the rules mito tables already have: windows and lookbacks are decided on the stored ticks, a kernel reads the time truncated to milliseconds, and samples less than a millisecond apart stay distinct. Histogram fields and range modifiers over such a time index decline as they do for mito. The time range is pushed into the scan in the stored unit for pruning. A second-precision time index takes the same path. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): decline every table with a `__name__` tag column The native route names each series it reads by its table and has no label to read a tag column named `__name__` as. Only file-engine tables were declined; a mito table with such a column ran natively and lost the column: two series that differ only in it came back as two rows with one label set, and `sum by (__name__)` folded them into one. The existing plan reads the column's values as the metric name instead. Such a schema has no Prometheus reading: a series has one `__name__`, and the table name already is the metric name. Decline it on every engine so the statement keeps the existing plan's answer. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): keep a window open until its last millisecond has been read A sample finer than a millisecond is placed in the window ending at the millisecond above it. A chunk that ends on such a sample has not read the rest of that millisecond, so treating that millisecond as settled closed the window before a later sample in the same millisecond arrived in the next chunk. Settle only up to the millisecond the last sample lies in, rounded down. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): select only an exact sample under a zero lookback A zero lookback admits only a sample exactly at the instant. The window time of a sample less than a millisecond before the instant rounds up to the instant, so the native selection picked it where the existing route returns nothing. Compare the stored tick with the instant when the lookback is zero, on the grid and anchored paths. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): cover zero lookback on microsecond and nanosecond file-engine tables A zero lookback selects only a sample stored exactly at the instant. A row source hands its time index over as stored, so a sample 0.5ms before the instant shares that instant's window time and was selected. The exact-match rule from the time index precision branch covers the row source as well; these cases pin it for file-engine tables in both precisions and check that legacy gives the same answer. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): cover a stale marker in the second field of a wide file-engine table A Parquet file-engine table with a microsecond time index and two DOUBLE fields: a row whose first field is valid and whose second holds a stale marker is selected on both routes, and a row stale in the first field is dropped on both, as the existing plan reads staleness from the first field only. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
2916062cc4 |
feat(promql): answer an instant query of a range selector natively (#10672)
* feat(promql): answer an instant query of a range selector natively An instant query whose root is a range selector, such as `x[5m]`, declined with matrix_root_without_a_grid. Prometheus and the existing plan answer it with the samples of the window, keeping their own timestamps and dropping stale markers. Those samples are exactly the points of a one-millisecond subquery over the same window at which the bare selector, read with no lookback, finds a sample. The planner now compiles such a root that way, reusing the subquery-root path, so `offset` and `@` place the window as they do for a subquery. A range query with a range-vector root still declines and fails as before. A zero-lookback instant selection now walks the samples instead of the grid points, and bounds its workspace by the sample count, so the fine grid costs no more than the samples it answers. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): cover the HTTP matrix of a native range selector root The instant query API now answers `x[5m]` on both routes with the same matrix, and a series with no sample in the window is omitted. The range selector finder also gets its own doc comment back. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): keep a range selector root's null rows and leave sub-millisecond windows to the existing plan Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): drop a range selector root's rows stale in any field Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): leave histogram range selector roots with an offset to the existing plan Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor(promql): keep any-field staleness specific to range selector roots Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): answer histogram range selector roots with an offset natively Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): leave range selector roots over sub-millisecond time indexes to the existing plan A range selector root runs as a one-millisecond subquery with no lookback. On a microsecond or nanosecond time index, a zero lookback selects only a sample exactly on a millisecond, so a sample between two grid points would be missing from the window. Decline the rewrite there. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * style(promql): format the range selector root time unit decline Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
5d3e22ce93 |
refactor(promql): report a declined shape instead of planning it the old way (#10701)
* refactor(promql): refuse with the recorded cause A native decline fails the offer instead of silently planning the statement again with the existing planner. Preserve upstream statement, alias and time-index shapes. Signed-off-by: discord9 <discord9@163.com> * refactor(promql): remove the dist-planner replan and the stale gates that fed it A statement the native route was asked for is planned once. The second planning pass with the route off, the gate that decided it, the histogram-aggregate refusal that cannot trigger, and the fallback option veto are gone; an unknown statement extension is refused by name. Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> |
||
|
|
fe01aeec89 |
feat(promql): run native PromQL over metric-engine physical tables (#10678)
* feat(promql): merge raw series that share a label set Add SeriesRouting::RawLabelSet: a raw router that routes by Prometheus label set and merges every stored series of one label set into one series, samples chained by timestamp like Prometheus' ChainedSeriesMerge. At a timestamp several stored series hold, the sample of the smallest primary key wins; pieces of one stored key must still agree there. A RawSeriesSource can ask for this merge. The flag is frontend-only: the router is placed where the source's frames arrive, above the region scan without a distributed planner and above the MergeScan with one. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): run native PromQL over metric-engine physical tables A selector naming a physical table used to keep the existing plan. The logical tables on it key their series by __table_id and __tsid, so two of them with equal labels store two series that Prometheus reads as one. The selector now reads through a RawSeriesSource that merges equal label sets, in standalone and across regions. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): merge physical-table label sets only above the merge scan Standalone hands the region the logical plan without serializing it, so the label-set flag reached the region and plan_raw_series_source added a second RawLabelSet router there. That buffered every region's answer twice, and a region could resolve a shared timestamp from its own share of the keys. The dist planner now gives MergeScanExec the source with the flag cleared and keeps the router above the merge scan. Planners without a dist planner still merge above the region scan. A single-chunk label set also skips the merge workspace. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): let a live sample win over a stale marker in label-set merges At one timestamp, the label-set merge now keeps the first sample that is not a stale marker in primary-key order, so a stale marker from one logical table no longer hides another table's sample. This matches the legacy plan, which drops stale markers before collapsing timestamps. The same-key conflict check now covers every key at the timestamp, not only the key that sorts first. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor(promql): skip the stale check for single-row timestamp groups Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
dca65604a9 |
feat(promql): answer an append-mode table, and any k for limitk (#10650)
* feat(promql): answer append-mode tables and any k for limitk The append-mode collapse compares raw ticks, so two distinct ticks inside one millisecond both survive and a same-tick tie keeps the last write. limitk picks its members by a hash of the label set with the label set as tie-break, so the membership no longer follows the order the inputs arrive in. Signed-off-by: discord9 <discord9@163.com> * test(promql): compare the golden limit cases by membership, not by pick Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> |
||
|
|
64943b35b6 |
feat(promql): read second, microsecond and nanosecond time indexes natively (#10671)
* feat(promql): read second, microsecond and nanosecond time indexes natively The native route declined every selector over a time index that is not in milliseconds. The existing plan wraps such a scan in a cast projection, so the decline surfaced as selector_plan_is_not_a_table_scan, and the region's raw series preflight refused the unit as well. The raw series path now hands ticks over in the stored unit, and each raw input of the native tree records that unit. Evaluation keeps the existing plan's semantics: windows and lookbacks are decided on the stored ticks, a kernel reads the time truncated toward zero to milliseconds after the offset, and samples less than a millisecond apart remain distinct samples. Since every bound is a whole millisecond, deciding membership on ceil(tick) in milliseconds is exact, so the evaluators keep a window time beside the payload only for microsecond and nanosecond inputs. Scan filters are built in the stored unit. Histogram fields and range modifiers over a sub-millisecond time index still decline. The append-mode decline is kept and renamed to append_mode_table. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): decline a discovered selector over mixed time index units Logical metrics on different physical tables can store their time index in different units, while the union a nameless selector reads is one native input bound to one unit. The union took the first source's unit and read the other sources' ticks in it, so a series stored in microseconds next to one in milliseconds dropped out of its windows. Such a selector now declines. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): keep a window open until its last millisecond has been read A sample finer than a millisecond is placed in the window ending at the millisecond above it. A chunk that ends on such a sample has not read the rest of that millisecond, so treating that millisecond as settled closed the window before a later sample in the same millisecond arrived in the next chunk. Settle only up to the millisecond the last sample lies in, rounded down. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): select only an exact sample under a zero lookback A zero lookback admits only a sample exactly at the instant. The window time of a sample less than a millisecond before the instant rounds up to the instant, so the native selection picked it where the existing route returns nothing. Compare the stored tick with the instant when the lookback is zero, on the grid and anchored paths. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): version the FusedSeries envelope for input time units Move BoundInput::time_unit out of the positional tree encoding and append the input leaves' units after the v1 payload as envelope v2. A v1 payload from an older build still decodes, with millisecond inputs. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): answer two selectors over different time units, and pin the mixed-unit decline reason Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): drop the retired series scan v2 switch from the mixed-unit case Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): expect the v2 FusedSeries envelope in the native prefix test Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): adapt the time-unit tests to upstream instant and discovery changes Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): name the mixed-unit discovery refusal as unsupported A native input carries one time unit, so discovery across physical tables with different time index units is refused. Answering needs a per-source rescale that changes the RawSeriesSource wire format; tracked in #10767. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
f824004131 |
feat(promql): segment native histogram folds above a split (#10675)
* fix(promql): declare float columns for a float function over a split histogram sum `histogram_count(sum(h))` and `histogram_quantile(0.9, sum(rate(h[2m])))` over native histograms failed to plan on the native route: the split counted the statement's value columns by the type of the exported state (a histogram), while the columns carry the root's kind (Float), so it counted zero and returned a plan error. Count value columns of either value type; the layout declares one kind for all of them. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): segment native histogram folds the split declines A single-input histogram tree whose fold the split could not carry - `sum(sum by (job) (h))`, `count(sum(h))`, `topk(1, sum by (job) (h))`, `sort`, `scalar` or `absent` over a fold, or a fold over a collapsing `label_replace` - declined to the legacy plan. Segmenting it is correct for histograms as it is for floats: the per-series prefix is cut into its own segment and the fold runs once over every segment's frames, so the gate is removed. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): assert the outer histogram fold runs natively above a split Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): assert the histogram fold reads frames from several partitions Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
d5fe65df3a |
feat(promql): run native PromQL over file-engine tables (#10680)
* feat(promql): run native PromQL over file-engine tables File-engine tables have no raw series scanner, so the native route declined them and they fell back to the legacy planner. Read such a table through a new RowSeriesSource node: an ordinary scan, filtered by the selector's matchers and time range, hash-partitioned by tags and sorted by (tags, time index, fields), then cut into explicit-label raw series chunks with Float64 values. The node declares its input distribution and ordering, so the physical optimizer inserts the repartition and a spillable SortExec. It stays above the merge scan, so it runs on the frontend in both standalone and distributed mode. Rows sharing labels and a timestamp keep one sample, as Prometheus storage does: the row whose field values sort lowest (nulls last). Non-string tags and histogram fields keep the existing plan. The cluster test builder can now pass the local file sandbox to datanodes and install frontend-only plugins, so the distributed case is covered. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): read file-engine tags as Prometheus label values A row source now reads every tag column as text with NULL read as '', so a NULL and an empty tag are one series from the start and an empty value carries no label, as in Prometheus. Rows of that series at one timestamp keep one sample by the existing rule. Matchers apply to the text form above the scan, so an integer tag matches "200" but not "0200". This drops the row_source_tag_is_not_a_string decline. The legacy planner fails on such a table with "Unsupported tag column type: Int64". Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): read native histogram fields from file-engine tables A row source passes a native histogram field on as histogram samples, converted with the same histogram_samples_from_arrow the mito raw scan uses, instead of casting every field to Float64. This drops the row_source_reads_floats_only decline, so the fixture of the sqlness case promql/delta_exponential_histogram runs natively; the integration test mirrors its statements and answers. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): read second-precision file-engine time indexes natively The existing scan plan already promotes a second-precision time index to milliseconds through a projection, which is exact. A row source now reads that projection instead of declining, and pushes the time range into the scan only when the scan's time index is in milliseconds. Microsecond and nanosecond time indexes still keep the existing plan. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): decline file-engine tables with a `__name__` tag column A row source dropped a tag column named `__name__` from its labels, sort key and partition key, so rows that differed only in that column merged into one series and lost samples. Mito's raw scan refuses such a tag. Decline it at planning time instead, and make RowSeriesSource reject the tag rather than filter it out. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): dedupe file-engine samples per field A row source reduced rows sharing labels and a timestamp to one whole row picked by the first field, so a NULL in another field of that row dropped the value a discarded row held there. Each field is its own value series: at a duplicated timestamp every field now keeps its own lowest non-null value (NaN above numbers, histograms by struct order). The sort key drops the fields, and the rows of the last timestamp of a batch are held back until the next batch, so every duplicated timestamp is reduced within one batch. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): rank NaN of either sign above numbers and bound the held-back run in RowSeriesSource Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(tests): install frontend plugins only when set so rebuilt clusters don't share them Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
88e98e60ed |
feat(promql): answer timestamp() over multi-field tables natively (#10670)
* feat(promql): answer timestamp() over multi-field tables natively The native compiler refused `timestamp()` over an input with more than one value field, so these statements fell back to the existing planner. A row of a multi-field table is one sample: the existing planner reports one `value` column holding the row's time wherever any field has a value. The native route now does the same. `timestamp` over several fields declares a single field, and both the selector form (sample time) and the evaluated form (evaluation time) report the time where any field of the row holds a value. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): read a native instant's stale marker from the first field only Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
426e3030da |
feat(promql): answer aliased TQL statements natively (#10669)
* feat(promql): answer aliased TQL statements natively `TQL EVAL ... AS name` (also used by CREATE FLOW) wraps the expression in an alias extension that the native compiler rejected, so these statements always fell back with `no_kernel_for_the_statement_shape`. The native route now offers the aliased expression and projects its rows into the layout the existing planner publishes: the value column under the alias, the labels, then the time index, with no metric name column. Labels follow the existing planner's order: a `by(...)` list keeps the order it names, `without(...)` sorts the rest, and a binary operation follows its vector operand. An alias over more than one value column fails with the same error the existing planner reports. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): take the aliased label order from the existing planner The alias layout guessed the existing planner's label order from the root's shape, which is wrong for `topk by(...)` (keeps its input's order), `count_values` (appends its label after the grouping), and any call or unary wrapper around a `by(...)` aggregate. The order is a by-product of planning the expression (`ctx.tag_columns`), so plan the aliased expression on the existing path with the native route off and project the native answer into that layout. A native answer whose label set differs from it declines, and the multi-value error now comes from the same field count the existing planner checks. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): fall back when a native output column name collides Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
ef1d505c2e |
fix(operator): reconcile inserts with auto-created tables (#10718)
* test: cover writes that need columns missing from the target table Each case writes columns that the table it reaches does not have: - a gRPC write to a new mito table whose CREATE loses to a concurrent writer, held after the DDL executor's existence check; - the same for a logical metric table, where the winner uses a nanosecond physical table and the losing write selected a millisecond one; - one gRPC batch with three entries for one new logical table and overlapping new tags; - one gRPC batch with two entries that need different new tags on an existing logical table; - an Elasticsearch _bulk request whose third document adds a field. Signed-off-by: dayan02dev <pawarudayan92@gmail.com> * fix(operator): check every auto-create request against the created table create_or_alter_tables_on_demand planned one CREATE for each request whose table was missing, and never checked the requests against the table that existed after the CREATE: - repeated entries for a new table in one batch sent one CREATE each. The later ones returned the first table without their columns, and repeated logical table names allocated several table IDs; - a CREATE that lost to a concurrent writer returned its own schema with the winner's table ID, so rows were converted against columns the region does not have; - a logical CREATE that lost returned the winner's table, but only tables found during planning were altered. Now the first request for a missing table defines its CREATE. A mito table is read back from the catalog after the CREATE, as logical tables already are, and every request for it is checked against that table. Missing columns go into one AddColumns per table, including tables found during planning, because an ALTER LOGICAL TABLES procedure reads each table once. Rows for a new logical table keep their timestamps until the table that exists is known, and are converted once. Signed-off-by: dayan02dev <pawarudayan92@gmail.com> --------- Signed-off-by: dayan02dev <pawarudayan92@gmail.com> Co-authored-by: dennis zhuang <killme2008@gmail.com> |
||
|
|
187facb58f |
feat(promql): let TQL discover metrics on the native route (#10674)
* feat(promql): let TQL discover metrics on the native route TQL statements never prepared a metric discovery scope, so the native route declined nameless and regex `__name__` selectors in TQL (`metric_discovery_unavailable`) and the legacy planner then rejected them, while the same query worked over the Prometheus HTTP API. SQL statement authorization now prepares the scope for the PromQL a statement evaluates (TQL EVAL/EXPLAIN/ANALYZE and TQL CTEs), keeping each discovered table that the statement's own permission request may read, and resolves the statement's table targets from the named tables plus that scope, as the HTTP path does. The returned context is the one the statement is planned with. A TQL CTE that discovers metrics publishes the native answer's columns: the legacy planner refuses such selectors, so there is no legacy schema to publish over it. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(frontend): pin TQL discovery to the statement's own permission request Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor(query): plan a metric-discovering TQL relation natively once Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
007f9dea40 |
feat(promql): rate delta-marked native histograms natively (#10676)
* fix(promql): declare float columns for a float function over a split histogram sum `histogram_count(sum(h))` and `histogram_quantile(0.9, sum(rate(h[2m])))` over native histograms failed to plan on the native route: the split counted the statement's value columns by the type of the exported state (a histogram), while the columns carry the root's kind (Float), so it counted zero and returned a plan error. Count value columns of either value type; the layout declares one kind for all of them. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): pick OTLP delta math per series in native rate and increase rate and increase over a table that carries otlp_aggregation_temporality declined with delta_temporality_under_rate_or_increase. The existing plan picks the math per series: a series marked "delta" holds increments, so increase is the Kahan sum of the window and rate is that sum over the range in seconds, while every other series keeps the counter math. A range evaluator of rate or increase over raw input now checks each series' labels when it starts and evaluates a delta series with the sum kernel, outside the batch path. A rate or increase that reads its window directly is admitted; one that reads it through another expression, a histogram field, or a range modifier still declines. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): cover offset and @ for native delta rate and increase Pins the delta sum against the existing plan when the window is moved by `offset` or anchored by `@`, and puts the misplaced doc comments of `kernel` and `root_subquery` back on their functions. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): rate delta-marked native histograms natively `rate` and `increase` over a native histogram whose series carries the OTLP delta temporality marker declined to the legacy plan. The legacy plan sums the window only for float samples and rates a native histogram as a counter whatever its marker says, so the native window already answers the same thing: the delta kernel only ever reads floats. The decline now applies to float selectors only, both for a call that reads the selector through another expression and for a range modifier. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): cover OTLP delta exponential histograms under native rate The earlier case wrote counter-hinted histograms through remote write. OTLP ingest stores a delta point as a gauge-hinted histogram whose start timestamp is the previous point's end; rate and increase over that shape now run natively and agree with the existing plan. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): sum delta-marked evaluated series under native rate and increase A float derived from a delta-marked native histogram, such as `increase(histogram_count(h)[2m:1m])`, keeps the OTLP temporality marker. The existing plan picks the delta math off that marker and sums the window, but the native window over an evaluated series always used counter math, so the two routes disagreed (40 vs 55 in the new case). Pick the delta kernel for an evaluated series the same way as for a raw one. Histogram windows still go through the histogram rules, which ignore the marker on both routes. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor(query): drop the unreachable range-modifier delta decline The native planner declined `rate`/`increase` over a delta-marked raw input when its window carried an anchored or smoothed modifier. Nothing in the query crate builds a `RangeModifier`, and promql-parser 0.10.0 does not parse either modifier, so the branch never ran. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): pin absolute values for native OTLP delta histogram rates The OTLP delta histogram test only compared the native route with the existing plan. Also assert the values the Prometheus formulas give for `histogram_count(increase(h[2m]))` (30 and 55) and for the subquery over `histogram_count` (55). Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor(promql): decide batch eligibility for a delta window in one check Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(query): run delta-marked float subqueries under native rate and increase `increase(m[2m:1m])` and `rate(m[3m:1m])` over a delta-marked float series declined to the existing plan, because the native window over an evaluated series used counter math. That window now picks the delta math from the marker its series keeps, as the existing plan does, so the decline and the `under_rate_or_increase` flag the selector walk carried for it are removed. The OTLP delta corpus test asserts both queries run natively, match the existing plan, and sum the window's deltas (divided by the range for `rate`). Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
b4f8bc2263 |
feat(promql): split rankings and rewrites above a fold, refuse an empty count_values destination (#10720)
* fix(promql): answer rankings above a fold, topk splits and label rewrites
topk and bottomk above a global aggregate used to be refused and silently
answered by the legacy path; they now split into a producer over raw samples
and a final fold that ranks the merged state. A label rewrite no longer loses
the operand, an empty discovery is answered instead of refused, and
count_values("") keeps its empty label instead of panicking.
Signed-off-by: discord9 <discord9@163.com>
* fix(promql): reject an empty count_values destination on both routes
Prometheus rejects an empty label name at evaluation, and our legacy planner
accepted it, so the two routes disagreed. The destination is now checked on
the existing path too, with the same message the kernel already emits.
Signed-off-by: discord9 <discord9@163.com>
* test(promql): drop the admission case an integer field no longer declines
The route answers integer fields as Float64 since #10668, so the matrix
asserting they stay out of it describes a contract the base no longer has;
native_fused_numeric_fields_answer_float64 covers the same shapes.
Signed-off-by: discord9 <discord9@163.com>
---------
Signed-off-by: discord9 <discord9@163.com>
|
||
|
|
dc683ebe14 |
feat(auth): make table permission checks schema-aware and guard flow … (#10708)
feat(auth): make table permission checks schema-aware and guard flow sink creation Signed-off-by: shuiyisong <xixing.sys@gmail.com> |
||
|
|
c573f9e87c |
feat(promql): answer integer fields natively as Float64 (#10668)
* feat(promql): answer integer fields natively as Float64 The native PromQL route declined statements whose legacy plan publishes an integer field's own type (bare selectors, sum over integers, count, count_values) with `field_keeps_its_own_type`. In Prometheus every sample is a float64, and the raw series scan already casts numeric fields to Float64, so the native route now answers these shapes with Float64 values instead of declining. Integer samples are cast before any fold, so a sum of integers beyond 2^53 follows float64 arithmetic, as Prometheus does. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): check the existing plan sums the large integers exactly Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
6ffb0ec793 |
feat: answer scalar COUNT on Mito from SST metadata (#9891)
* feat: answer scalar COUNT on Mito from SST metadata Behind `experimental_metadata_aggr` (off by default), ScanHintRule marks an ungrouped scalar COUNT directly over a Mito scan. Mito then proves the scan's row count without reading SST data. Every file intersecting the query time range must be covered by the static predicates and have a known manifest row count. In deduplicating regions it must also share no (time, primary key) point with another file or a memtable, and its `__op_type` Parquet statistics must show no deletions. The statistics are read through the SST metadata caches, only for files that pass the manifest checks. RegionScanExec publishes the proven count as exact statistics, which lets DataFusion replace the scan with a literal. Other scans are unchanged. Overlaps are found with one time sweep over a segment tree of compressed primary key bounds, in O(N log N). The pairwise check remains as the test oracle and benchmark baseline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: aumnertic <aumnertic@gmail.com> * test(mito): cover metadata COUNT and address core review Signed-off-by: aumnertic <aumnertic@gmail.com> * test(mito): match metadata aggregate fixture region IDs Signed-off-by: aumnertic <aumnertic@gmail.com> * fix(mito2): prove SST row counts before publishing exact statistics Signed-off-by: aumnertic <aumnertic@gmail.com> * test(mito2): add SQLness coverage for the SST footer marker Signed-off-by: aumnertic <aumnertic@gmail.com> * test(mito2): verify tightened partition bounds and source estimates Signed-off-by: aumnertic <aumnertic@gmail.com> * fix(mito2): keep lazy footer reads sendable Signed-off-by: aumnertic <aumnertic@gmail.com> * test(mito2): use valid sequence fences and SST owners Signed-off-by: aumnertic <aumnertic@gmail.com> * fix(mito2): validate SST key bounds before metadata count Signed-off-by: aumnertic <aumnertic@gmail.com> * fix(mito2): verify SST time bounds before metadata count Signed-off-by: aumnertic <aumnertic@gmail.com> * fix(mito2): own SST inputs to asynchronous bound checks Signed-off-by: aumnertic <aumnertic@gmail.com> * test(mito2): match displayed scan names in COUNT fallback Signed-off-by: aumnertic <aumnertic@gmail.com> * fix(mito2): keep SST replacements coherent with metadata counts Signed-off-by: aumnertic <aumnertic@gmail.com> * refactor(cmd): reuse the replacement SST reader during validation Signed-off-by: aumnertic <aumnertic@gmail.com> * test(mito2): verify listed SST sizes against object storage Signed-off-by: aumnertic <aumnertic@gmail.com> * fix(mito2): keep metadata count proofs within the SST read set Signed-off-by: aumnertic <aumnertic@gmail.com> * docs(mito2): use the actual scan memory limit key Signed-off-by: aumnertic <aumnertic@gmail.com> * fix(mito2): gate metadata counts on trusted SST dedup markers Record the provenance of engine-written dedup markers in the manifest. Clear it for external imports and preserve it during internal transfers. Require this proof for metadata counts over non-append multi-row SSTs. Keep the live file metadata consistent when an import supersedes a background publication, and cover checkpoint downgrade and reopen. Signed-off-by: aumnertic <aumnertic@gmail.com> --------- Signed-off-by: aumnertic <aumnertic@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
89990fa715 |
fix(promql): preserve precision in native histogram range sums and av… (#10657)
* fix(promql): preserve precision in native histogram range sums and averages Signed-off-by: shuiyisong <xixing.sys@gmail.com> * test(promql): cover avg_over_time overflow before histogram downscale Signed-off-by: shuiyisong <xixing.sys@gmail.com> --------- Signed-off-by: shuiyisong <xixing.sys@gmail.com> |
||
|
|
4d8e55909a |
feat(promql): fold native histograms over multi-input trees natively (#10677)
* feat(promql): fold native histograms over multi-input trees natively A histogram statement reading more than one selector through raw sources declined as soon as it needed placement, so `sum(h1 + h2)`, `sum without (instance) (h1 or h2)` or `histogram_count(sum(h1 + h2))` ran their fold on the legacy plan. Such a tree is segmented like a float one: each operand's per-series prefix publishes frames, and the fold runs once above all of them with histogram state. A bare vector-vector pairing of histograms keeps the composed plan, one frame per operand. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * feat(promql): run histogram pairs over raw sources natively Drop the gate that sent a vector-vector histogram pairing to the composed binary route. Evaluated as one node over both raw sources, `h1 + h2`, `sum(h1 + h2) * 2` and their kin answer the same values, so the gate only fixed a plan shape. The tests that pinned that shape now assert the pairing and its answer instead, and two stale comments say what the kind walk and the segment gate actually do. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): pin that a histogram pair reads both raw sources With the pairing gate restored, the composed route still roots a Binary with the same fills and columns, so the test passed either way. Assert that each operand is an instant selection over its own raw source, which only the single-node route builds. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
9fc061d125 |
feat(promql): apply OTLP delta math per series in native rate and increase (#10673)
* feat(promql): pick OTLP delta math per series in native rate and increase rate and increase over a table that carries otlp_aggregation_temporality declined with delta_temporality_under_rate_or_increase. The existing plan picks the math per series: a series marked "delta" holds increments, so increase is the Kahan sum of the window and rate is that sum over the range in seconds, while every other series keeps the counter math. A range evaluator of rate or increase over raw input now checks each series' labels when it starts and evaluates a delta series with the sum kernel, outside the batch path. A rate or increase that reads its window directly is admitted; one that reads it through another expression, a histogram field, or a range modifier still declines. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): cover offset and @ for native delta rate and increase Pins the delta sum against the existing plan when the window is moved by `offset` or anchored by `@`, and puts the misplaced doc comments of `kernel` and `root_subquery` back on their functions. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor(promql): decide batch eligibility for a delta window in one check Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
86a81cc91d |
fix: pre-encode sparse primary keys for exemplar and SQL writes (#10625)
* fix: pre-encode sparse primary keys for exemplar and SQL writes Signed-off-by: shuiyisong <xixing.sys@gmail.com> * fix: preserve sparse write guards and WAL policy Signed-off-by: shuiyisong <xixing.sys@gmail.com> * perf: skip sparse key decoding on initial routing Signed-off-by: shuiyisong <xixing.sys@gmail.com> * fix: preserve sparse primary key order across upgrades and repartitioning Signed-off-by: shuiyisong <xixing.sys@gmail.com> * fix: reject exemplar writes without destination preflight Signed-off-by: shuiyisong <xixing.sys@gmail.com> * test: compact sparse partitions before merging Signed-off-by: shuiyisong <xixing.sys@gmail.com> * fix: clippy Signed-off-by: shuiyisong <xixing.sys@gmail.com> * test(compat): drop git-commit version constraint Signed-off-by: shuiyisong <xixing.sys@gmail.com> * refactor: simplify sparse write and exemplar paths Signed-off-by: shuiyisong <xixing.sys@gmail.com> * refactor: remove sparse key order check Signed-off-by: shuiyisong <xixing.sys@gmail.com> --------- Signed-off-by: shuiyisong <xixing.sys@gmail.com> |
||
|
|
fe4c603ea8 |
refactor(mito2): retire Parquet series and range indexes (#10709)
* refactor(mito2): retire Parquet companion indexes and two-phase series scans Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito2): read native series files with SST lifetime pins Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito2): remove retired scan and cache plumbing Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito2): finish isolating Narthex scan preparation Signed-off-by: evenyag <realevenyag@gmail.com> * test(mito2): verify retries while a failed range reader is pinned Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito2): import the set used by Narthex partition filters Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito2): remove stale series scan errors and lint failures Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito2): centralize Narthex manifest paths Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito2): propagate per-series scan errors and account for buffered batches Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito2): use Narthex names for series-index maintenance Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito2): read Narthex samples through the owning SST handle Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito2): keep the original Parquet series distributor Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com> |
||
|
|
9aebf3a821 |
fix(delete): route deletes using partition columns on value-partitioned tables (#10710)
fix(query,operator): retain partition columns when routing delete requests Preserve non-key partition columns across DataFusion DML delete projection and Deleter::trim_columns so RowSplitter evaluates partition expressions against the row's actual value rather than NULL, and cover trim_columns schema/row alignment in operator unit tests. Fixes #10705 Signed-off-by: Ömer <60585342+zaidrain06@users.noreply.github.com> |
||
|
|
3be82bd956 |
fix: parse csv numbers from text for BIGINT UNSIGNED and with skip_bad_records in COPY FROM (#10643)
* fix: parse csv numbers from text for BIGINT UNSIGNED and with skip_bad_records COPY FROM a csv file read a BIGINT UNSIGNED column with the inferred type, so 9007199254740993e0 went through a Float64 and lost its last digit, or turned into NULL when the column was inferred as a string. With skip_bad_records the DECIMAL and BIGINT UNSIGNED columns were read by Arrow's csv reader. It dropped the digits of a decimal beyond the scale, returned 0.00 for some numbers in scientific notation, and rejected 0e0 and unsigned integers in scientific notation, so those records were skipped. Both csv paths now read such a column as a string and parse it from its text, like the json path does. Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com> * fix: parse numbers for the table type with skip_bad_records The skip_bad_records reader takes its column types from the table. The columns to parse from text were still chosen by the inferred type, so a BIGINT UNSIGNED column inferred as a boolean from a first value of true went back to Arrow's reader, and a later 9007199254740993e0 was skipped. Choose them by the table type there. Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com> --------- Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com> |
||
|
|
15ca57ca20 |
fix(promql): publish legacy columns for native TQL in CTEs and flows (#10666)
* fix(promql): keep the native name column out of TQL CTEs and flows The native rows layout always appends a per-row `__name__` column. The Prometheus HTTP response reads it, but two SQL-visible consumers took it as part of the statement's columns: - A hybrid CTE published it after the existing planner's columns, so `WITH t (ts, val) AS (TQL EVAL ... metric)` failed with a column count mismatch on the native route. - A TQL flow matched it against the sink table and failed with "found 4 flow output columns and 3 sink table columns". A CTE now publishes exactly the existing planner's columns over the native plan. A TQL flow plans its query with the native route off, like CREATE VIEW does, because its output columns are the sink table's schema and the native route also names value columns differently. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(flow): plan TQL flows on the native route with the existing columns The previous commit kept a TQL flow's sink schema stable by forcing the existing PromQL planner. Plan it like a TQL CTE instead: run natively and publish the existing planner's columns over the native plan. `LogicalPlanner::plan_relation` plans a statement whose columns are read by SQL. The CTE path and `sql_to_df_plan` both use it. The standalone test harness now starts the flow consistency check task, which `ADMIN FLUSH_FLOW` syncs with, so the flow test can run the flow and compare the sink table and rows with the existing route's. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): pair per-series columns by role when a TQL CTE or flow runs natively publish_legacy_schema paired the columns it could not match by name by type alone, so a series with two string labels left both label columns ambiguous and the statement fell back to the existing plan. Per-series outputs such as rate(), topk(), offset binaries and label_replace() over a table with more than one tag never ran natively in a CTE or a flow. Pair the time index by its marker, labels by name, and the remaining value columns in order, with the same casts as before. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test: start the flow check task only in the flow test The standalone harness started the flow consistent-check task for every instance. The task runs on the global runtime and holds the flow engine, and nothing stopped it, so it outlived the instance and each rebuild started another one. The harness now exposes the flow engine, and the flow test that needs ADMIN FLUSH_FLOW starts the task and stops it. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): check a two-field TQL CTE keeps each value column The native route pairs value columns with the existing ones by position. Two fields with different values make a swapped pair visible. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * style: format the two-field CTE test Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(flow): key a TQL sink table on every label of the answer The sink table of a TQL flow took its primary key from the innermost aggregate when the plan had one. In `m / scalar(sum(m))` that aggregate groups by time alone, so the labels of `m` were created as DOUBLE fields, written as NULL, and every series collapsed into one row per timestamp. The native route has no such aggregate and keyed on the labels, so the two routes created different sinks for the same flow. Every string column of a PromQL answer is a label of its output series, so the sink now keys on all of them on both routes. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(flow): keep writing a TQL sink that has the native __name__ column Before TQL flows were planned with `plan_relation`, a native TQL flow auto-created its sink from the native plan's own columns: the value named by that route, the labels, and `__name__` as a primary key column. The relation plan publishes neither, so such a flow failed sink validation and stopped writing. When the sink has a `__name__` column, plan the statement with `plan`, which is what these flows ran before. They keep writing the same columns and the same `__name__` values: the metric name for a selector, NULL where PromQL drops the name. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
c2a66803ff |
fix(mito2): read narthex tables partitioned on a non-tag column (#10665)
* fix(mito2): report one identity for a narthex series across regions Prepared narthex reads with explicit labels prefixed each series key with the region id. The prefix dates from when identity was the (table_id, tsid) hash and kept colliding series in different regions apart. Since #10330 the key is the exact sparse key, so the prefix protects nothing, but it still gives the fragments of one series in two regions different primary keys. SeriesRepartitionExec groups raw chunks by primary key, so those fragments never met in one owner: native PromQL returned duplicate series or failed with "input repeated an exact series identity" on a time-partitioned table. Use the exact key as the only candidate key and drop the separate merge key. The storage-api and raw chunk docs now require the identity to be the same in every region instead of allowing a region-qualified one. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(mito2): filter narthex rows by a non-tag partition rule A narthex scan applied the region's partition rule to series-index rows during discovery. Those rows carry tags only, so a rule on any other column, such as `PARTITION ON COLUMNS (ts)`, failed to compile against them, and every read of such a region failed with "Failed to coerce partition expr against the schema", in SQL and PromQL alike. Keep series-level filtering for rules that reference tags only. Apply any other rule to sample rows, with the series' own values for the tags the rule references, since a file shared after repartition can hold rows of both partitions within one series. Compaction reads without the region predicate, so this filter is the only thing that keeps the other partition's rows out of its output. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): check native reads of a time-partitioned narthex table Every series of a narthex table partitioned on the time index is split across two regions. Native PromQL over it, and SQL, must answer like the same rows held whole in one default-storage region, standalone and distributed. This covers both the partition rule on sample rows and the region-independent series identity that lets the frontend merge the fragments. The promql guide no longer claims that a series split across regions is not merged. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(mito2): value __table_id from the series in a sample partition rule A partition rule that mixes `__table_id` with a non-tag column, which repartitioning a metric table can produce, is evaluated on sample rows. The filter looked `__table_id` up among the series' tag values, where the series index never puts it, so every read of such a region failed with "missing partition tag". Take it from the series' table ID instead. The time-partition test now also covers a tag + time rule and a `__table_id` + time rule. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): say which sample conflicts across regions and why A raw merge that finds two different samples of one series at one timestamp now names the series and the timestamp, and gives the likely cause: a table partitioned on a non-tag column, with the sample written on both sides of a partition bound, so each region kept one version. Behavior is unchanged; the query still fails. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
95e69f80c3 |
fix(promql): plan a float function over a split native histogram sum (#10663)
fix(promql): declare float columns for a float function over a split histogram sum `histogram_count(sum(h))` and `histogram_quantile(0.9, sum(rate(h[2m])))` over native histograms failed to plan on the native route: the split counted the statement's value columns by the type of the exported state (a histogram), while the columns carry the root's kind (Float), so it counted zero and returned a plan error. Count value columns of either value type; the layout declares one kind for all of them. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
8d4e9464d9 |
feat(mito): store native histograms in narthex samples (#10667)
* feat(mito): store native histograms in Narthex samples A physical table whose single value field is the canonical greptime_native_histogram struct can now use sst_format = 'narthex'. The samples format gets column encoding 8, which lays out a block's histogram field child by child: each struct child is encoded with the nullable XOR codec of encoding 5, integers ZigZag-mapped, and a list as its nullable lengths followed by its flattened items. The chunk header names the child count and child kinds, the manifest records the field type as "native_histogram", and a block whose field chunk encoding does not match its manifest type is rejected. Writers and bulk memtable parts cut a block before a histogram chunk's size bound would pass the 1 MiB chunk limit, and a Narthex region rejects a sample that cannot fit one chunk before accepting the write. The prepared columnar reader now serves histogram fields, so native PromQL raw scans read Narthex histogram regions; float-only projections still skip histogram chunks. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(mito): cover Narthex histogram bulk limits and sidecar reads Add tests for paths the histogram change relies on but no test pinned: the bulk write path refusing an oversized histogram sample before WAL and memtable, the bulk memtable splitting large histograms into blocks whose chunks stay within the samples chunk limit, and native PromQL reading histograms from a columnar series-index sidecar on a Parquet metric table, compared with the plain Parquet answer. Also wrap three long lines in the samples format doc. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs(mito): state that the block size formula does not bound histogram buffers Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(mito): release read-ahead before failing a histogram reservation Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs(mito): pin the native histogram chunk layout and child order Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(mito): check bulk histogram sizes after filling missing columns Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
59b108af84 |
fix(procedure): recover from the last readable checkpoint (#10612)
* fix(procedure): recover from the last readable checkpoint Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(procedure): keep unreadable checkpoints out of GC checks Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(procedure): use the SNAFU selector for corrupt checkpoints Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: WenyXu <wenymedia@gmail.com> |
||
|
|
0127d63865 |
fix(mito2): require a region to own its files before a remap (#10646)
* fix(mito2): require a region to own its files before a remap A remap (split or merge) moves file references between regions. Today mito2 checks only that the inputs come from the same table, so a merge can be applied while a participant still holds files another region created; a later compaction then materialises a copy of the same rows and both references survive the file-id dedup, so the merged region reads those rows twice. Reject such a remap instead: every participating region must hold only files whose creation expression equals that region's own partition expression. The error names each offending (region, file, creator expression) so the caller can compact the region and retry. A one-source-to-many-targets split is exempt: no target combines file sets there and the region predicate keeps a split's rows apart. This trades a merge-time error and a compaction for the per-reference row range that #10616 adds. Signed-off-by: discord9 <discord9@163.com> * fix(mito2): treat a file without a recorded creator as the region's own Files written before the partition expression was recorded carry no creator, so their provenance cannot be established and the read path does not narrow them either. The merge guard compared such a file against the region's expression and rejected it, which would break the first repartition of an upgraded table. Also state the remedy as it is: the operator aborts the repartition, compacts and retries; nothing triggers that compaction automatically, and a region in a staging session is skipped by the compaction scheduler, so the abort comes first. Signed-off-by: discord9 <discord9@163.com> * fix(mito2): report only the region and file that a merge must settle The refusal does not need to restate either partition expression: the operator acts on the region, and no production caller parses the message. Drops the expression rendering and its now unreachable None arm. Signed-off-by: discord9 <discord9@163.com> * docs(mito2): drop the comments the trimmed diagnostics left behind Removes the orphaned renderer doc, stops the unit-test comment from promising creator diagnostics, describes the error payload as it is, and corrects the claim that a creator-less file is not narrowed on read. Signed-off-by: discord9 <discord9@163.com> * fix(mito2): reject an unstamped file on merge, and bound the refusal message An unstamped SST can still hold rows of both children of an earlier split, so letting it through a merge re-admits the duplicate: both children inherit it, one compacts into its own file, and the merged region then holds the same rows under two file ids. A split stays exempt, so an unstamped table can still repartition; its regions materialise (compaction stamps the output) before merging. Lists at most eight offending files and counts the rest, so a wide table cannot produce an unbounded message. Signed-off-by: discord9 <discord9@163.com> * fix(mito2): check merge ownership before the target routes are published The remap-time guard fires while fetching manifests, which the procedure does after UpdateMetadata::ApplyStaging has published the target write routes: a reused target can acknowledge a write that the rollback then routes elsewhere, and the row is flushed later under the old expression. Move the decision ahead of publication. Every incoming edge to ApplyStaging now asks each merge source leader, through RemapManifest with a validate-only flag, whether every file it holds records its own expression; the check reads the ordinary manifest, writes nothing and leaves the region out of staging. A refusal therefore keeps the old routes in force. The flag is serde-defaulted, so an older datanode ignores it and its ordinary remap is refused because the region is not in staging - a failure, not a silent pass. The remap-time guard stays as the second line of defence. The failure now reaches the SQL caller with the offending region and file: Collect keeps the sub-procedure errors instead of only their counts. Signed-off-by: discord9 <discord9@163.com> * fix(meta-srv): keep the refusal's cause and its retryability Collect formatted the child failure with Display alone, so ProcedureExec's "Failed to execute procedure" hid the region and file the operator needs; render the whole source chain instead, and assert in the test that the parent error names a known region and file. A mailbox timeout on the pre-publication check became a terminal "compact the region" error, although metasrv treats the timeout as retryable. Propagate anything whose retry hint is retryable, and build the offender list - and its compaction advice - only from non-retryable failures. Signed-off-by: discord9 <discord9@163.com> * fix(mito2): use one predicate for merge ownership at both stages Preflight skipped every single-source group, while the remap guard exempted only a one-to-many mapping: a one-to-one repartition could therefore be refused after the target routes were published. Both stages now read the same rule from the persisted mapping - a group needs the check iff some target is fed by two or more distinct sources - expressed once in store-api and used by the preflight and by is_split. A one-to-one repartition hands its target one source's files and combines nothing, so it is exempt at both stages instead of being refused late. Signed-off-by: discord9 <discord9@163.com> * test: materialise before merging in the repartition integration tests Both tests merge regions that still reference an SST written by an ancestor, which the merge guard refuses. Compact with the strict-window mode first - it rewrites even a lone inherited file - and keep the merges they were written for. Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> |
||
|
|
c887958b03 |
Merge commit from fork
Add query.remote_allowed_hosts and query.allow_server_credentials to frontend, datanode and standalone. - query.remote_allowed_hosts: when set, object stores built from SQL statements send every request, including credential requests, through an HTTP transport that only allows the listed hosts and does not follow redirects. Blocked requests are logged with their host and port. - query.allow_server_credentials = false: an object store without credentials in its connection options cannot use the server's own credentials. Independent of the options, explicit credentials are validated: incomplete S3/OSS key pairs, an S3 session token without keys, an Azure account key without a known account name, and a GCS credential that is not a service account key are rejected. Only the type, private key and client email of a GCS service account key are passed to the signer. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> |
||
|
|
82dec23d17 |
fix(query): prune logical metric scans by table ID (#10645)
* fix(query): prune logical metric scans by table ID Signed-off-by: evenyag <realevenyag@gmail.com> * perf(query): skip redundant single-region metric pruning Signed-off-by: evenyag <realevenyag@gmail.com> * perf(query): skip table ID pruning for tag-only metric routes Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com> |
||
|
|
686005c2c9 |
feat(mito): build native series indexes with certified time-window coverage (#10615)
* feat(mito): stream exact sample keys into native PoC series files Signed-off-by: evenyag <realevenyag@gmail.com> * feat(mito): evaluate native series window frontiers in the pinned scan Signed-off-by: evenyag <realevenyag@gmail.com> * feat(mito): publish native window builds through serialized region edits Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): validate full index coverage across publication and recovery Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): repair incompatible native indexes and isolate sidecar capacity Signed-off-by: evenyag <realevenyag@gmail.com> * test(mito): fill the sidecar budget in native repair coverage Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): remove source file IDs from native series indexes Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): release memtable snapshots before native index I/O Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): preserve local sidecar source list encoding Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): expose Narthex series entry to production writer Signed-off-by: evenyag <realevenyag@gmail.com> * feat: build incremental Narthex series indexes from manifest coverage Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): reuse series indexes across compatible schema changes Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): simplify native series index coverage and publication Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): require a window for native series indexes Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): remove tag rename handling from series index reads Signed-off-by: evenyag <realevenyag@gmail.com> * feat(mito): batch native series index builds by uncovered file count Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): configure the native series index file threshold via TOML Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com> |
||
|
|
83dd79491a |
fix: honor LIMIT when copying a table to a file (#10639)
* fix: honor LIMIT when copying a table to a file Signed-off-by: Alex <alex.castillog33@gmail.com> * test: verify zero-row COPY CSV output Signed-off-by: Alex <alex.castillog33@gmail.com> * style: format COPY LIMIT regression setup Signed-off-by: Alex <alex.castillog33@gmail.com> --------- Signed-off-by: Alex <alex.castillog33@gmail.com> |
||
|
|
51082c6d4e |
feat(promql): answer the shapes the native route refused for want of a rule (#10611)
* feat(promql): answer the shapes the native route refused for want of a rule Three refusals in the native fused route were admissions, not missing capability. Each is answered here against main's own structure. **Grouping by `__name__` over several sources.** A tree reading more than one named source could not report the label a `by (__name__)` keeps, because only a discovered source declared it. Every metric-bound input now declares its name as a source tag when the tree reads more than one, and the two refusals that guarded this - in the planner and in `segment_tree` - are gone with `groups_by_metric_name`. **A `__field__` matcher over an input with no table.** The matcher names the only field layout such an input can declare, so it answers an empty frame of that field. An operator other than `=` stays refused: it asks what set of fields the tables carry, and there is no table to ask. **A canonical merge over a partitioned table.** `per_source_inputs` now covers `any_partitioned && contains_canonical_merge`, so the boundary's producer runs above the regions and reads a raw-series source instead of a bare scan, which is what the distributed planner already does. Two smaller rules complete the kind walk: `output_field_kind` covered Window, Instant, Map, Binary and Aggregate and fell through for the rest, so a statement rooted at a vector operation, `info` or a parameterized map named no kind at all - each answers a kind already written one arm away, and the catch-all is gone so a variant added later has to be classified. A comparison between two different kinds produces no sample (`elem_binop` skips it), so its column is the empty float layout the arithmetic arm already names. Finally, a value field is classified by what the raw series scan produces rather than by its catalog type, and admitted where the statement's shape makes the existing planner publish `Float64` for it too: arithmetic, `min`/`max`, the float-answering aggregates and the range functions whose value window is a float. A `BIGINT` table's `sum(m)` and its bare `m` stay refused - DataFusion's `sum` answers `Int64`, and a bare selector copies the column's own type, so admitting either would publish a column the existing plan publishes differently. Signed-off-by: discord9 <discord9@163.com> * test(promql): pin a whole-vector operator standing on an aggregate The kind walk now names what a vector operation answers, so a ranking over an evaluated aggregate plans on this route - and the split declines it, which keeps the route rather than losing it: `split_aggregate` answers `None` and segmentation takes the whole statement. Both facts are load-bearing enough to pin. The plan-level test asserts a fused node and no final split for `topk`, `bottomk`, `limitk`, `limit_ratio` and `sort` over an aggregate, with a bare-scan control; the integration test compares the rows the two routes answer for the shapes both of them can run, and inspects the plan that actually executed to confirm the ranking sits above the evaluated input. Signed-off-by: discord9 <discord9@163.com> * fix(promql): an integer fold is not a float once something casts it The numeric admission asked what type the existing plan publishes for a field, and read every arithmetic operator as publishing `Float64`. That is true of the operator, not of what it wraps: `sum(v) * 1` over `BIGINT` sums the integers first and casts afterwards, so `9007199254740993` and `-9007199254740992` answer `1.0` there, while the raw scan casts each value before summing and answers `0.0`. Admitting that shape would have answered a different number. An arithmetic operator now publishes a float only when the fold under it does too. `sum(int_field) * 1`, `sum(int_field) + 1` and `count(m) + 1` keep the existing plan; `sum(rate(m[5m]))`, `m * 2` and the aggregates that answer a float of their own stay native. The series-scan preflight refused the raw path for every field of an ordinary table whenever the store was configured columnar, and nothing above could turn that refusal into a fallback, so a query `main` answered with 40 became a planning error. Only the prepared columnar reader is gated now: a table whose region needs preparation keeps the refusal, and one that merely lacks columnar coverage is served by the ordinary scan. The test that pinned the error is replaced by one that pins the answer: a columnar-configured store over ordinary `INTEGER` and `FLOAT` tables answers `sum_over_time` and `avg_over_time` from the ordinary scan, equal to the existing route. Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> |
||
|
|
22807a772e |
perf(promql): stop building label-set tables where they cannot collide (#10514)
* perf(promql): stop building label-set tables where they cannot collide Signed-off-by: discord9 <discord9@163.com> * fix(promql): let a canonical merge sit below a split aggregate Signed-off-by: discord9 <discord9@163.com> * test(promql): identify native pieces by what they read, not by rendered text Signed-off-by: discord9 <discord9@163.com> * perf(promql): judge a metadata drop by its labels alone The plan-time proof of whether two series can share a canonical label set asked two things: whether the labels tell them apart, and whether the scan's key columns do. The second half was defensive against storage series that differ only in a nullable tag holding NULL versus an empty string, which canonical comparison already treats as one label set. Every tag column of a metric-engine table is nullable, so that half was false for ordinary tables, and a root merge was inserted above point-wise shapes that cannot fold two series at all. A deep binary was cut into pieces by it, and a disjoint scan went from two routers to four. Judge the drop by the labels only. The physical partition-identity rule keeps its own copy of the key-column question; the plan no longer reads it, and a scanner whose pieces one storage series can reach is still collected under its primary key before any name-dropping kernel sees them. Signed-off-by: discord9 <discord9@163.com> * test(promql): admit a histogram fold on a nullable table, name the risk counter The fold-admission test ran on a stable-key fixture, which hid that the shapes it names decline on a nullable one; run it on the metric-engine fixture instead. A drop above a fold needs no collection there, which a new test pins. Rename what the plan could not prove from "skipped" to "unproved" throughout, including the test hook, now that the counter counts that rather than a collection. Signed-off-by: discord9 <discord9@163.com> * fix(promql): a kernel that answers one series per label set proves the drop above it `100 * (1 - avail / size)` kept a canonical merge above its vector-vector match. The match already files its rows by the result label set and refuses two values of one field at one point, so the broadcast above it removes a name no two of its series were told apart by; judging that drop by its sources alone got it wrong. A fold, a match between two vectors, a set operation, `info`, `count_values` and the histogram functions answer one series per label set by construction, and the proof now says so. A merge is deliberately not one of them: it answers one series per *canonical* label set, which still carries the name, so a drop above it can fold `a{job="x"}` and `b{job="x"}` and must be collected. With the proof fixed, the ranking case no longer collects between the fold and the sort, so the test that pinned the old shape now reads the fold inside the ranking's own tree. Signed-off-by: discord9 <discord9@163.com> * test(promql): a fold may plan as a collected split With the drop judged by its labels alone, `sum(label_replace(...))` no longer keeps a collection above the fold, so the fold plans as partial state per partition with the canonical merge below it instead of a complete aggregate over assembled series. The rows, the legacy comparison and the cross-partition collision all stay the same, so the three assertions that pinned the complete shape now accept either, and check that the merge is still there. Signed-off-by: discord9 <discord9@163.com> * fix(promql): derive a window's labels as the runtime drops them A window that drops the metric name removes every metadata label at runtime (`__name__`, `__type__`, `__unit__`), but the plan derived only `__name__` as gone. A fold above such a window was therefore judged unproved - it could still see a `__unit__` the runtime had already removed - and collected a canonical merge. That merge made the segment non-commutative with a bare scan under it, so the admission gate declined the whole statement and it was quietly replanned as legacy. Derive the labels the runtime leaves behind instead. The test that pinned the old derivation now says both things it was covering: a scan that still carries `__type__` is still collected, and a map that already removed it is not. Signed-off-by: discord9 <discord9@163.com> * test(promql): a single-metric drop needs one fused node, not two With the drop judged by its labels alone, `histogram_arithmetic * 2` on a single-metric table needs no root merge, so the statement runs as one fused node instead of a producer and a consumer. Accept either count and say why. Signed-off-by: discord9 <discord9@163.com> * fix(promql): report a cross-partition label-set collision instead of folding it A label rewrite that gives two series one label set is collected by a canonical merge, and a split keeps that merge inside its per-partition prefix. Two colliding series that landed in different partitions were therefore each folded apart, and the state router added the two partial states - a value no label set ever stood for - where Prometheus reports `vector cannot contain metrics with the same labelset`. Refuse the split across a canonical merge, in `split` and in `admit_prefix`, so the statement takes the boundary shape instead: each partition's producer collects what its own scan holds, the canonical router routes every piece of one label set to one owner, and the fold above reads whole series. Two colliding series are then reported wherever they were scanned. A discovered selector is a union of one source per metric, so a segment over it already reads frames that name their own metric: accept it in `build_evaluated_segment` the way `build_inner_segment` already does, which keeps `{host="a"}`-style selectors from declining once the split no longer carries them. A histogram fold above a boundary has no execution on this route (only the split's state carries one), so those statements keep the plan they have on `main`; the existing route reports their collision through its window function. Signed-off-by: discord9 <discord9@163.com> * docs(promql): the drop chain pays one merge, not the key columns The example claimed the merge was paid over a table whose key columns can spell the `NULL`/`''` pair. That pair is not part of the labels' proof any more, so no merge is paid for it: the merge in the example is the one the chain's first drop pays, and every drop above a merge asks only about the metadata labels. State that instead of a cause that no longer exists. Signed-off-by: discord9 <discord9@163.com> * test(promql): keep the pair the labels cannot prove apart The window test asked the pass for a metric-less selection, so the collection it asserted was paid for by the multi-metric guard rather than by the pair the test is about. `zone=""` and an absent `zone` meet after `rate` even when the metric name is known, and #10412 caught that with a node-level occupancy tracker. That tracker is gone here: the drop is judged by the labels alone, and the empty value a kernel also removes is deliberately outside that proof - collecting it would put a canonical merge over every statement whose kernel drops the metadata labels. The pair therefore leaves the window as two pieces of one label set, which the PR description records under "What this gives up" and "Out of scope". The case is restored as the shape #10412 approved and marked ignored with that reason, so the behaviour it pins stays in the record instead of being dropped again; the metric-less case it had replaced is kept as its own test. Also drops a disjunct `is_sourced_plan` already covers. Signed-off-by: discord9 <discord9@163.com> --------- Signed-off-by: discord9 <discord9@163.com> |
||
|
|
1110a0af36 |
fix(meta): preserve table column order and primary key indices during reconciliation (#10251)
* fix(meta): preserve table column order and primary key indices during reconciliation Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * fix(meta): address maintainer review on column order and PK validation during reconciliation Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * style(meta): simplify nested if blocks in reconciliation utils Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * test(meta): use OutputData::pretty_print for SHOW CREATE TABLE verification Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * test(meta): drop unused mut in reconcile_table integration test Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * test(meta): make reconcile SHOW CREATE TABLE assertion formatting-tolerant Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * test(meta): cargo fmt reconcile assertion Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * test(integration): parse quoted SHOW CREATE output in reconcile test Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * style(tests): rustfmt reconcile_table SHOW CREATE assertions Signed-off-by: Tyagiquamar <104281681+Tyagiquamar@users.noreply.github.com> Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * style(tests): fix clippy collapsible str replace in reconcile_table Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * fix(meta): address reconcile_table review on tests and docs Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * test(integration): fix q8 SHOW CREATE TABLE assertion with check_output_stream Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> * fix(meta): take reconcile primary key order from the region tags build_table_meta_from_column_metadatas preserved the stale table_meta primary key order, so a consistent reconcile kept the post-ADD-COLUMN key (a, b) instead of restoring the regions' [b, a] and a later UseMetasrv SyncColumns rewrote the region key over SSTs encoded with the old order. The key order now follows the input tags, which the reconcile paths feed in region key order; the ResolveColumnMetadata consistent branch re-applies reorder_tag_columns so the region's key must match its tag columns. Column order still comes from table_meta for #10249. cargo test -p common-meta reconciliation: 41 passed. Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * style(meta): wrap the tag-order loop for rustfmt Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * fix(meta): address reconcile_table review on test fixtures and guards Address review comments from @WenyXu and @killme2008: - Add ALTER TABLE q8 ADD COLUMN c INT before table reconciliation to exercise stale key repair with added columns. - Remove redundant else-continue guard in the tag ordering loop. - Clarify rustdoc explaining physical versus logical table reconciliation paths. - Share new_test_q8_raw_table_info fixture helper across reconciliation tests. Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> * test(meta): cover partition key order during reconciliation Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Tyagiquamar <mohdquamartyagi@gmail.com> Signed-off-by: Tyagiquamar <104281681+Tyagiquamar@users.noreply.github.com> Signed-off-by: Dennis Zhuang <killme2008@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: dennis zhuang <killme2008@gmail.com> |
||
|
|
f4ff272f37 |
fix: keep exact DECIMAL and BIGINT UNSIGNED values in COPY FROM csv and json (#10560)
* fix: keep exact DECIMAL and UInt64 values in COPY FROM csv and json Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com> * style: format the reader schema test Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com> * test: add the expected output of the exact numbers case Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com> * fix: round decimals with extra fractional digits in COPY FROM Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com> * fix: parse decimals from text in COPY FROM csv and json Arrow's decimal decoding is wrong for some numbers in scientific notation and drops the digits beyond the scale. Read a decimal column as a string and parse it, so that every digit is used and the value is rounded as the cast from a float did. Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com> * fix: read unsigned integers from text and reject empty strings in COPY FROM json Arrow's json reader parses an integer in scientific notation through a Float64, so 9007199254740993e0 lost its last digit in a BIGINT UNSIGNED column. Such a column is now read as text and parsed from every digit, like a DECIMAL column. An empty json string loaded into a DECIMAL column as NULL. It is an error again, and only an empty csv field is read as NULL. Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com> --------- Signed-off-by: Samarth Jaiswal <samarthjaiswal30@gmail.com> |
||
|
|
8e885bfed5 |
feat(promql): read the quantile parameter at every grid point (#10509)
`quantile(scalar(foo), v)` and `quantile(time()/2400, v)` were refused by the native compiler, which
bound the quantile with `constant_argument`. Prometheus reads an aggregate's parameter at every step,
and the kernel already does: `aggregate_quantile(schema, input, q: &Series, grouping)` looks the
quantile up per grid point and answers nothing where the parameter has no sample.
A scalar the statement evaluates now binds as a parameter subtree, in the shape `topk` already uses:
`NativeExpr::ParameterizedAggregate { input, op, parameter }` is appended to the enum (wire index 18;
the enum is append-only), so no field is added to `Aggregate` and the envelope version is unchanged.
`op` keeps its constant quantile unused, exactly as `ParameterizedTopK` ignores the `k` it carries.
A parameter the statement itself decides stays on the constant path - `quantile(0.25 + 0.1 + 0.15, v)`
is one number - and a vector argument keeps the refusal it always had, which the parser now states
first: `quantile(x, y)` is refused at type check before this compiler sees it.
The fold drains the parameter whole before its input, bills the held series in `QuantileInput`'s
bytes and settles what it no longer holds, so the pool is empty at the end. Validation accepts the
node only for a `Complete` quantile whose parameter is a scalar on the output grid, and a split still
declines a quantile, so no `Partial` or `Final` state can exist for it.
Signed-off-by: discord9 <discord9@163.com>
|
||
|
|
216135381b |
feat(mito): integrate opt-in authoritative Narthex storage (#10526)
* feat(mito): integrate opt-in authoritative Narthex storage Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): restrict Narthex storage to one value field Signed-off-by: evenyag <realevenyag@gmail.com> * fix(cmd): handle Narthex in direct SST fixture writer Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): clarify Narthex encoded bulk part support Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): type Parquet bulk iterator inputs explicitly Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): route Narthex storage by region format Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): address authoritative Narthex review findings Signed-off-by: evenyag <realevenyag@gmail.com> * docs: remove implementation notes from samples format spec Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): rely on canonical metric write keys Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): refine Narthex scan and copy semantics Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): reject raw sparse writes and exclude series scans from windowed sort Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): allow sparse bulk companion tags and simplify manifest admission Signed-off-by: evenyag <realevenyag@gmail.com> * refactor(mito): make Narthex scan preparation optional Signed-off-by: evenyag <realevenyag@gmail.com> * fix(mito): prune Narthex samples in stored time units and share bulk blocks Signed-off-by: evenyag <realevenyag@gmail.com> * test: track sparse exemplar write failures Signed-off-by: evenyag <realevenyag@gmail.com> * test: track remaining observed sparse exemplar failures Signed-off-by: evenyag <realevenyag@gmail.com> * test: isolate sparse write regressions across ingestion paths Signed-off-by: evenyag <realevenyag@gmail.com> --------- Signed-off-by: evenyag <realevenyag@gmail.com> |
||
|
|
f796889bbd |
feat(postgres): jsonl COPY FROM STDIN via the arrow-json engine (#10109)
* feat(postgres): Prometheus Remote Write protobuf ingest via COPY FROM STDIN COPY FROM STDIN WITH (FORMAT promwrite [, version 2] [, <options>]) ingests one Prometheus Remote Write request body over the postgres wire protocol — a GreptimeDB-specific, binary COPY format (wire format code 1). The payload is byte-for-byte the body a remote-write client POSTs to /v1/prometheus/write, compression included: buffered until CopyDone and completed through the exact ingestion core that endpoint runs. To share that core, the HTTP handlers' ingestion bodies are extracted into axum-free functions (ingest_remote_write_v1/v2 plus the context extension stamping), and the HTTP routes become thin wrappers — their behavior is unchanged, and the copy layer runs the identical decode, validation, conversion, batched/prepared write paths, per-batch write-progress accounting and context extensions, under the connection's regular postgres context. The WITH options carry what the HTTP endpoint takes as its content-type/-encoding and query parameters; session-provided values (database, user) are not repeated: - version 1|2 (default 1), matching the content-type's proto - zstd, matching Content-Encoding: zstd (snappy by default) - physical_table, matching the ?physical_table= parameter - pipeline_name/pipeline_version, matching the pipeline headers (v1 only; for v2 they are accepted and ignored, exactly like the HTTP route ignores them) Table-less like the other ingestion formats; one COPY statement is one bounded request (shared 64 MiB limit); the row count reports written rows (v1) or written samples plus histograms (v2). The flush enforces the frontend's shared request-memory quota (max_in_flight_write_bytes) — the same limiter the HTTP ingestion protocols use, so COPY cannot bypass the aggregate budget. Wiring: PostgresServer::with_prom_remote_write carries the handler, metric-engine flag, validation mode and shared memory limiter. e2e: v1 body chunked across CopyData boundaries; v2 samples with readback; physical_table option routing; garbage-body decode failure with connection reuse; a tiny-quota regression where a compressed body whose decompressed size exceeds the budget fails like the HTTP route. Signed-off-by: Ning Sun <sunning@greptime.com> * feat(postgres): jsonl COPY FROM STDIN via the arrow-json engine COPY tbl [(cols)] FROM STDIN WITH (FORMAT jsonl) ingests newline-delimited JSON objects through arrow-json's incremental Decoder — the same engine behind file-based COPY ... FROM 'file.json' — so both COPY routes accept identical data. One JSON object per record; keys address the targeted columns by name, absent keys become NULL, and offset-free timestamp strings parse in the session timezone (the same schema substitution the csv codec makes), like SQL INSERT. The streaming contract mirrors arrow-csv's exactly (decode returns consumed bytes; a short read means a full batch), so the parser is a twin of the csv one: objects may span CopyData chunk boundaries, records surface in COPY_IN_FLUSH_ROWS batches, and a trailing object without its newline is accepted. Table-bound like csv (a named table is required; the column list fixes the target order); no options (the file format's layout options are writer-side; the reader parses date-times natively). The two table-bound codecs share the table path through a small TableBoundCodec trait (check_column_type + create_parser); csv's behavior is unchanged. e2e: chunked object-boundary ingest with absent-key NULLs; session-timezone parity against SQL INSERT; malformed JSON failure with table-left-clean and connection recovery. Signed-off-by: Ning Sun <sunning@greptime.com> * feat(postgres): address jsonl COPY review — codec names, nullable-aware errors, docs and tests - `TableBoundCodec::name()` drives the codec name `CopyInState` logs instead of the hardcoded "csv"; `table_bound_state` reuses the query context `begin_copy_in` created; the csv/jsonl trait impls hold their bodies and share one supported-type check. - jsonl: the decode schema marks every field nullable, so a NULL in a non-nullable column is reported by column name instead of arrow-json's "unmasked nulls in non-nullable StructArray child" error; errors map to 22P02/22P04 by semantics (field value vs. syntax), never XX000; the no-op `decode(&[])` EOF signal is gone; a top-level JSON array under `FORMAT json` fails with a specific hint instead of `expected { got [`. - Module docs describe what arrow-json really accepts: numeric strings for numeric columns, numeric timestamps taken in the column's unit, unknown keys ignored (strict mode stays off so column subsets work). - Tests: multi-batch sweep through the mid-stream flush path, trailing and truncated records, column subset/reorder with extra keys, missing and null ts, the `json` alias, error classes. Signed-off-by: Ning Sun <sunning@greptime.com> --------- Signed-off-by: Ning Sun <sunning@greptime.com> |
||
|
|
b948fb78b1 |
fix(promql): plan absent_over_time over a nameless multi-metric selector (#10512)
`absent_over_time({job="x"}[20m])` was declined by the native route, and the plan it fell back to
answers with an error, so the shape produced no answer at all: the existing planner needs one
`__name__` equality matcher to read a table from (`Expect a metric matcher, but not found`).
The guard that declined it assumed that a nameless selector's tree declares `__name__` while binding
no metric name, and that the fused node refuses such a tree. That is not the shape: a discovered
selector's prepared input is the `Union` of one `RawSeriesSource` per metric, so the node is handed
explicit-label frames, and only its bare-region-scan arm reads the binding's name - an arm a nameless
selector never reaches, because a successful scan always binds one metric. A statement such as
`sum by (__name__) ({tag_0="x"})` over discovered metrics already builds and runs exactly this
combination.
The guard now declines only a nameless input that is not already sourced, which keeps the bare-scan
arm closed if that invariant ever regresses. The presence fold keeps the metric name, so two metrics
sharing ordinary labels stay two series and `absent` answers the empty vector, as Prometheus does;
a fold that dropped the name would have folded them into one series and answered wrongly.
`is_sourced_plan` is the existing predicate factored out of the child mapping, so the guard and the
mapping ask the same question. `FusedSeriesBinding::metric_name`'s doc no longer claims the logical
node requires a name whenever `tags` declares `__name__`; the requirement belongs to the bare-scan
arm of the physical planner.
A statement that mixes a multi-metric discovery with a single-metric selector was admitted and then
failed at physical planning: `build_inner_segment`'s multi-source arm wrapped every prepared plan in
a new `RawSeriesSource`, including plans that were already sources, and built
`RawSeriesSource(RawSeriesSource(TableScan))`, which the physical planner refuses after the statement
has been committed to this route. The arm now hands an already-sourced plan to the segment as it is
and wraps only real table scans (`is_sourced_plan`).
Regression: `absent_over_time({job="api"}[5m]) or ({probe_label="y"} + on(job) absent_a)` was
unanswerable before that fix and now runs a `FusedSeriesExec` and answers
`(120000, {job="api"}, 7.0)` and `(400000, {job="api"}, 1.0)`.
Not changed: a statement whose discovered table is partitioned still declines, because
`remote_raw_boundary` skips this builder and the alternative does not recognise a `Union`.
Signed-off-by: discord9 <discord9@163.com>
|
||
|
|
0ce4799e48 |
feat(query): opt-in experimental factorized join aggregation rewrite (WIP) (#9546)
* feat(query): opt-in experimental factorized join aggregation rewrite Add an experimental shape-based rewrite for AVG(value * weight) and SUM(value * weight) over an inner equi-join grouped by (host, area), turning it into per-side preaggregates joined and combined in a projection. Opt-in via the new query option experimental_enable_factorized_join_agg (default false), settable per session with SET. The rule is registered always and gates at rewrite time. Approximation contract documented: well-conditioned inputs match baseline to ~1e-9; heavy cancellation/overflow may diverge and is accepted in this opt-in mode. WIP: config/config.md regeneration pending (make config-docs, needs Docker). Draft. Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(query): finish switch wiring, config docs, engine-level opt-in test Declare the count_join module without the test gate, register the rule unconditionally, and read FactorizedJoinAggOptions at rewrite time (default off -> Transformed::no). Replace the ported fixture suite with an engine-level test comparing plans with the switch off and on. Regenerate config/config.md (make config-docs). Verified: cargo nextest -p query 815 passed / 2 skipped; -p cmd 94 passed; fmt and clippy clean on touched crates. The SQL SET path is not yet covered by a test. Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(query): address review findings on factorized join aggregation Address the blind review of PR 9546: - Admission no longer keys on table/column names: the matcher accepts any inner equi-join of two single-table inputs grouped by (left key, right group column) with one AVG/SUM over a product of two Float64 payload columns, either operand order. Renamed tables rewrite; qualified names work. - Operand/group/key columns resolve through intermediate projections and must be exact pass-throughs; a projection that computes or renames them keeps the baseline plan (previously the rewrite read the raw column and silently dropped the computation). - The rule now fires behind the distributed planner: scan detection recurses through the recovering projection, MergeScan extension, filters, and subquery aliases. Verified by an engine-level test built with the dist planner enabled. - Payload columns must be Float64; Int64/Decimal inputs keep the baseline plan instead of producing mixed-type expressions. - Session SET experimental_enable_factorized_join_agg = false now overrides a server-level true; an unset session inherits the server default (tracked via an explicit set flag). - Renamed rule/module to factorized_join_agg, dropped unused COUNT partial aggregates and stale docs, restored the QueryOptions doc. - Tests: 8 engine-level cases covering renamed tables, result parity within 1e-9 with NULL/valid=0 semantics, computed-alias rejection, Int64 rejection, near-miss shapes, opt-in default, dist-planner firing, and SET override propagation. Verified: cargo nextest -p query 822 passed / 2 skipped; -p cmd 94 passed; fmt clean; clippy clean on touched code. Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(query): projection operand scope and atomic session setting Address the post-fix review of PR 9546: - Product operands extracted from a projection expression reference the projection INPUT, so they are no longer re-resolved through the projection's output schema; only aggregate-argument columns resolve through it, and the unqualified name-only fallback is removed — a missing qualified column never silently matches an unrelated same-named column. Regression: a projected product with same-named columns on opposite sides rewrites with the correct payload columns; the projected-product positive shape is now admitted. - The session setting is one ArcSwap<Option<bool>> (None = unset, inherit server default; Some(v) = explicit override). Clone loads a single atomic snapshot; the previous value/flag pair could clone a state that never existed under a concurrent first SET. Clone preservation tests cover unset, explicit false, explicit true. - Tests: computed-payload rejection keeps the grouping columns unchanged so payload validation is the decisive condition; added SUM rewrite parity and reversed-operand AVG parity. Verified: cargo nextest -p query 824 passed / 2 skipped; -p session 17 passed; fmt clean; clippy clean on touched code. Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test(query): sqlness case for the factorized join aggregation switch Add a standalone sqlness case exercising the experimental rewrite end to end through the MySQL protocol on one connection: default off, SET experimental_enable_factorized_join_agg = true enabling it (EXPLAIN shows the partial count/sum aggregates joined with the CASE reconstruction), AVG/SUM result parity including the NULL (valid=0) group, a non-matching shape left alone, and SET false turning the rewrite back off. The case must run entirely on the MySQL protocol: session-level SET only propagates within the same connection, and sqlness sends unannotated statements over gRPC with a fresh query context. Verified with cargo sqlness bare -t factorized_join_agg (passes twice in a row on a rebuilt greptime binary); query 824 passed / 2 skipped; session 17 passed. Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(query): preserve factorized aggregate schema and count semantics Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * test(query): refresh factorized join agg sqlness expectation for MergeScan pushdown Upstream #10221 pushes the column projection through MergeScan, so both the baseline and the rewritten plans now show the projection inside the remote input instead of above it. Regenerated with `cargo sqlness bare -t factorized_join_agg`. All 52 changed lines are Projection/ProjectionExec/MergeScan reordering; result rows, group counts, and the partial aggregate shape are unchanged, and both the standalone and distributed environments pass. Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> * fix(query): make partial aliases collision-free and refresh CI expectations Address the post-ready review of PR 9546: - The four partial-aggregate aliases are now collision-free against every field name visible to the rewritten aggregates: `join.left.schema()`, `join.right.schema()` and `agg.input.schema()` (the last one includes the optional projection above the join). A real column literally named `partial_nv_1` used to land next to the qualified grouping key of the same bare name in a partial aggregate's output schema, which DFSchema rejects as ambiguous. `aliases_do_not_collide_with_column_names` reproduces that shape (left join/group key `partial_nv_1`, right group column `partial_nw_3`) and asserts both switches plan and produce identical output. - Both EXPLAIN statements in the new sqlness case now carry `-- SQLNESS REPLACE (peers.*) REDACTED`, so the expected output no longer embeds allocation-dependent node IDs; the case passed standalone but failed in the full suite because of them. - Regenerated `common/tql-explain-analyze/explain.result`: registering the rule adds one `logical_plan after factorized_join_agg_rewrite` row per EXPLAIN statement (all `SAME TEXT AS ABOVE`, since the rule leaves those plans unchanged). - `tests-integration/tests/http.rs`: the expected config-API TOML now includes `experimental_enable_factorized_join_agg = false` right after `allow_query_fallback`, matching the field order in `QueryOptions`. Verified on this head: `cargo nextest -p query factorized_join_agg` 13 passed; sqlness `factorized_join_agg` and `tql-explain-analyze` pass in standalone and distributed; `integration_http_file_test::test_config_api` passes; `cargo fmt` clean; clippy `-p query -p tests-integration --all-targets -- -D warnings` clean. Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> --------- Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com> |
||
|
|
517a1376e2 |
fix(otlp): reject malformed cumulative histogram points (#10552)
* fix(otlp): reject malformed cumulative histogram points Signed-off-by: shuiyisong <xixing.sys@gmail.com> * refactor(otlp): check bucket sum overflow once Signed-off-by: shuiyisong <xixing.sys@gmail.com> --------- Signed-off-by: shuiyisong <xixing.sys@gmail.com> |
||
|
|
788df5849b |
fix(metric): route logical table writes by internal table id (#10366)
* fix(metric): pass logical table identity to partition evaluation Signed-off-by: WenyXu <wenymedia@gmail.com> * test(metric): cover table-id repartition routing across storage formats Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(partition): validate logical routing inputs Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(metric): retain table ids for physical batch routing Signed-off-by: WenyXu <wenymedia@gmail.com> * refactor(partition): simplify table-id routing paths Separate context dispatch, routing input construction and column conversion into private methods while preserving the scalar payload path. Reuse the existing table-id constant and shared IPC decoding in tests. Keep correctly routed requests intact when their partition version is unchanged. Update existing retry coverage to use stale versions for rerouting and verify unchanged bulk requests preserve alignment and ownership. Signed-off-by: WenyXu <wenymedia@gmail.com> * fix(servers): validate table-id column row count Report mismatched logical table identities before Arrow column construction, document batch and row ordering requirements, and remove the unreachable batch skip. Extend the existing conversion test and clarify the partition evaluation context contract. Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: WenyXu <wenymedia@gmail.com> |
||
|
|
d21322e222 |
fix: chunk RDS batch operations within parameter limits (#10489)
* fix: chunk RDS batch operations within parameter limits Signed-off-by: WenyXu <wenymedia@gmail.com> * fix: deduplicate MySQL batch reads and use a regular CI database Signed-off-by: WenyXu <wenymedia@gmail.com> * fix: preserve consistency across RDS batch reads Signed-off-by: WenyXu <wenymedia@gmail.com> * refactor: use sqlx begin_with for MySQL transactions Signed-off-by: WenyXu <wenymedia@gmail.com> * fix: use read-only snapshots for RDS batch reads Signed-off-by: WenyXu <wenymedia@gmail.com> --------- Signed-off-by: WenyXu <wenymedia@gmail.com> |