Files
greptimedb/tests
dayan02devanddennis zhuang f1b4dc695e fix(query): stop reporting CTEs as missing tables in range queries (#10397)
* test(query): cover range queries over derived inputs without a time index

A range query over a CTE or an aliased subquery whose columns carry no
time index fails with `Table not found: greptime.public.<alias>` (#5839),
while the same input without an alias reports `Cannot find time index
column`. Plan all three shapes in a planner test and expect the time
index error, and add the CTE case to the `range/error` sqlness case.

Signed-off-by: dayan02dev <pawarudayan92@gmail.com>

* fix(query): report missing time index for range queries over CTEs

`RangePlanRewriter::get_index_by` resolves each field qualifier of the
range input as a table. A CTE or subquery alias is not a table, and the
resulting `TableNotExist` was skipped only when some field still carried
time index metadata. Without that metadata it was returned as is, so a
range query over such a CTE failed with `Table not found:
greptime.public.<cte>` (#5839).

Skip qualifiers that are not tables in every case. The input then falls
through to the existing time index metadata fallback or to
`TimeIndexNotFound`, which the same input already gets without an alias.

Signed-off-by: dayan02dev <pawarudayan92@gmail.com>

* test(query): drop derived-input time index unit test covered by sqlness

Signed-off-by: dayan02dev <pawarudayan92@gmail.com>

---------

Signed-off-by: dayan02dev <pawarudayan92@gmail.com>
Co-authored-by: dennis zhuang <killme2008@gmail.com>
2026-11-23 20:20:51 +00: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 🥳!