Commit Graph
7 Commits
Author SHA1 Message Date
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
Ruihang Xia 0d90f7407c fix: infer time index from column meta on derived table (#8013)
* rough fix

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* reorganize

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* simplification

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* fix format

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* add comment

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* enhance default by infer

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* supply comments

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* update sqlness result

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
2026-05-12 08:18:46 +00:00
85d564b0fb fix: upgrade sqlparse and validate align in range query (#5958)
* fix: upgrade sqlparse and validate align in range query

* update sqlparser to the merged commit

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
Co-authored-by: Zhenchi <zhongzc_arch@outlook.com>
2025-04-25 17:34:49 +00:00
WU Jingdi fb4da05f25 fix: adjust fill behavior of range query (#3489) 2024-03-13 09:20:34 +00:00
WU Jingdi 806400caff feat: add align to / interval support in range query (#2842)
* feat: add align to / interval support in range query

* chore: fix ci

* chore: simplify `parse_duration_expr`

* chore: change s to ms
2023-12-04 08:00:41 +00:00
WU JingdiandRuihang Xia 91820a8006 fix: empty by in range query (#2770)
* fix: empty by in range query

* Apply suggestions from code review

---------

Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
2023-11-17 11:18:14 +00:00
WU Jingdi 46e106bcc3 feat: allow nest range expr in Range Query (#2557)
* feat: eable range expr nest

* fix: change range expr rewrite format

* chore: organize range query tests

* chore: change range expr name(e.g. MAX(v) RANGE 5s FILL 6)

* chore: add range query test

* chore: fix code advice

* chore: fix ca
2023-10-18 07:03:26 +00:00