Files
greptimedb/tests-integration/src
dennis zhuang 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>
2026-12-01 06:41:53 +00:00
..