Files
greptimedb/tests
discord9 a1be266c3c fix(promql): ignore histogram samples in scalar() and share one kernel (#10426)
* fix(promql): ignore histogram samples in scalar() and share one kernel

Prometheus' funcScalar counts only float samples: histogram samples are ignored silently,
so they neither supply a value nor make a point hold more than one element. The select
kernel rejected them instead, while the native ScalarOf runtime kept its own inline loop
that ignored them, so scalar(histogram_metric) answered differently depending on the
route.

The kernel now ignores histogram samples and the runtime calls it, deleting the inline
copy. A point with one float answers that float, with only histograms or with several
floats answers the Go NaN.

The kernel builds its answer as one dense run over the grid: a Vec<f64> seeded with the
Go NaN, where the first float at a point writes its value and a second writes NaN back,
plus the counts the caller already reserves. That buffer becomes the result's Float64Array
by move, so the per-point peak is the 8 bytes of values plus 1 of counts the reservation
already counts. Staging through Vec<Option<f64>> and GridSeriesBuilder would have held
about 33 bytes per point against a 9-byte reservation.

Signed-off-by: discord9 <discord9@163.com>

* refactor(promql): resolve the evaluation grid once in scalar()

grid_points already resolves and validates the grid, so asking for the schema's grid again
right after could only disagree with what was just checked.

Signed-off-by: discord9 <discord9@163.com>

* chore(compat): move the from-versions window to v1.3.1

v1.3.1 has published release assets, so the compatibility check asks for it and fails on
every branch that still names v1.3.0.

Signed-off-by: discord9 <discord9@163.com>

---------

Signed-off-by: discord9 <discord9@163.com>
2026-11-16 14:57:32 +08:00
..

Sqlness Test

Sqlness manual

Case file

Sqlness has two types of file:

  • .sql: test input, SQL only
  • .result: expected test output, SQL and its results

.result is the output (execution result) file. If you see .result files is changed, it means this test gets a different result and indicates it fails. You should check change logs to solve the problem.

You only need to write test SQL in .sql file, and run the test.

Case organization

The root dir of input cases is tests/cases. It contains several subdirectories stand for different test modes. E.g., standalone/ contains all the tests to run under greptimedb standalone start mode.

Under the first level of subdirectory (e.g. the cases/standalone), you can organize your cases as you like. Sqlness walks through every file recursively and runs them.

Kafka WAL

Sqlness supports Kafka WAL. You can either provide a Kafka cluster or let sqlness to start one for you.

To run test with kafka, you need to pass the option -w kafka. If no other options are provided, sqlness will use conf/kafka-cluster.yml to start a Kafka cluster. This requires docker and docker-compose commands in your environment.

Otherwise, you can additionally pass the your existing kafka environment to sqlness with -k option. E.g.:

cargo sqlness bare -w kafka -k localhost:9092

In this case, sqlness will not start its own kafka cluster and the one you provided instead.

Run the test

Unlike other tests, this harness is in a binary target form. You can run it with:

cargo sqlness bare

It automatically finishes the following procedures: compile GreptimeDB, start it, grab tests and feed it to the server, then collect and compare the results. You only need to check if the .result files are changed. If not, congratulations, the test is passed 🥳!