test(sql): record fused multi-selector semantic regression

Twenty rows over four series cover the two-occurrence forms the fused
planner admits (default addition, order-sensitive subtraction, an
explicit full-key join and a bool comparison) plus the shapes that must
stay on the legacy path: different matchers, group_right, an anchored
rate with offset, an aggregation and a subquery. The result file is
generated by the pinned sqlness runner; a second run reproduced it byte
for byte. This case proves SQL semantics only: the per-query native hint
is not sent by this runner, so native routing and multi-partition
execution are verified separately over HTTP.

Signed-off-by: discord9 <55937128+discord9@users.noreply.github.com>
This commit is contained in:
discord9
2026-10-23 19:35:34 +08:00
parent 988ac3616b
commit 73faca0ecb
2 changed files with 199 additions and 0 deletions
@@ -0,0 +1,144 @@
-- SQL semantic regression; actual native routing and multi-partition execution verified separately over HTTP.
-- One insert and one flush keep the fixture small; this runner does not prove scan partitioning.
-- Four series, one sample per second. Instant selectors below evaluate at 4s, so their last values
-- are h1/left 5, h1/right 50, h2/left 10, h2/right 100.
CREATE TABLE fused_multi_standalone (
host STRING,
kind STRING,
ts TIMESTAMP(3) TIME INDEX,
val DOUBLE,
PRIMARY KEY (host, kind),
);
Affected Rows: 0
INSERT INTO fused_multi_standalone VALUES
('h1', 'left', 0, 1), ('h1', 'right', 0, 10), ('h2', 'left', 0, 2), ('h2', 'right', 0, 20),
('h1', 'left', 1000, 2), ('h1', 'right', 1000, 20), ('h2', 'left', 1000, 4), ('h2', 'right', 1000, 40),
('h1', 'left', 2000, 3), ('h1', 'right', 2000, 30), ('h2', 'left', 2000, 6), ('h2', 'right', 2000, 60),
('h1', 'left', 3000, 4), ('h1', 'right', 3000, 40), ('h2', 'left', 3000, 8), ('h2', 'right', 3000, 80),
('h1', 'left', 4000, 5), ('h1', 'right', 4000, 50), ('h2', 'left', 4000, 10), ('h2', 'right', 4000, 100);
Affected Rows: 20
ADMIN FLUSH_TABLE('fused_multi_standalone');
+---------------------------------------------+
| ADMIN FLUSH_TABLE('fused_multi_standalone') |
+---------------------------------------------+
| 0 |
+---------------------------------------------+
-- Both occurrences are the same full-key selector, combined by default matching addition.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} + fused_multi_standalone{host!="",kind!=""};
+------+-------+---------------------+-------------------+
| host | kind | ts | lhs.val + rhs.val |
+------+-------+---------------------+-------------------+
| h1 | left | 1970-01-01T00:00:04 | 10.0 |
| h1 | right | 1970-01-01T00:00:04 | 100.0 |
| h2 | left | 1970-01-01T00:00:04 | 20.0 |
| h2 | right | 1970-01-01T00:00:04 | 200.0 |
+------+-------+---------------------+-------------------+
-- Subtraction is order sensitive: each series must be minus its own last value.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} - (fused_multi_standalone{host!="",kind!=""} * 2);
+------+-------+---------------------+----------------------------------------------------------------------+
| host | kind | ts | fused_multi_standalone.val - fused_multi_standalone.val * Float64(2) |
+------+-------+---------------------+----------------------------------------------------------------------+
| h1 | left | 1970-01-01T00:00:04 | -5.0 |
| h1 | right | 1970-01-01T00:00:04 | -50.0 |
| h2 | left | 1970-01-01T00:00:04 | -10.0 |
| h2 | right | 1970-01-01T00:00:04 | -100.0 |
+------+-------+---------------------+----------------------------------------------------------------------+
-- The same two selectors, added with an explicit full-key join.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} + on(host, kind) fused_multi_standalone{host!="",kind!=""};
+------+-------+---------------------+-------------------+
| host | kind | ts | lhs.val + rhs.val |
+------+-------+---------------------+-------------------+
| h1 | left | 1970-01-01T00:00:04 | 10.0 |
| h1 | right | 1970-01-01T00:00:04 | 100.0 |
| h2 | left | 1970-01-01T00:00:04 | 20.0 |
| h2 | right | 1970-01-01T00:00:04 | 200.0 |
+------+-------+---------------------+-------------------+
-- Equality with bool keeps all four series and reports 1 for each.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} == bool fused_multi_standalone{host!="",kind!=""};
+------+-------+---------------------+-------------------+
| host | kind | ts | lhs.val = rhs.val |
+------+-------+---------------------+-------------------+
| h1 | left | 1970-01-01T00:00:04 | 1.0 |
| h1 | right | 1970-01-01T00:00:04 | 1.0 |
| h2 | left | 1970-01-01T00:00:04 | 1.0 |
| h2 | right | 1970-01-01T00:00:04 | 1.0 |
+------+-------+---------------------+-------------------+
-- Different matchers cannot share one fused scan; on(host) keeps host: h1 55 and h2 110.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{kind="left"} + on(host) fused_multi_standalone{kind="right"};
+------+---------------------+-------------------+
| host | ts | lhs.val + rhs.val |
+------+---------------------+-------------------+
| h1 | 1970-01-01T00:00:04 | 55.0 |
| h2 | 1970-01-01T00:00:04 | 110.0 |
+------+---------------------+-------------------+
-- group_right keeps the right-side kind: h1/left 10 and h1/right 55.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{kind="left",host="h1"} + on(host) group_right fused_multi_standalone{host="h1"};
+------+-------+---------------------+-------------------+
| host | kind | ts | lhs.val + rhs.val |
+------+-------+---------------------+-------------------+
| h1 | left | 1970-01-01T00:00:04 | 10.0 |
| h1 | right | 1970-01-01T00:00:04 | 55.0 |
+------+-------+---------------------+-------------------+
-- Raw-table anchor: @ 3 with offset 1s ends the 3s window at 2s, although evaluation is at 4s.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') rate(fused_multi_standalone[3s] @ 3 offset 1s);
+---------------------+----------------------------------------+------+-------+
| ts | prom_rate(ts_range,val,ts,Int64(3000)) | host | kind |
+---------------------+----------------------------------------+------+-------+
| 1970-01-01T00:00:04 | 1.0 | h1 | left |
| 1970-01-01T00:00:04 | 10.0 | h1 | right |
| 1970-01-01T00:00:04 | 2.0 | h2 | left |
| 1970-01-01T00:00:04 | 20.0 | h2 | right |
+---------------------+----------------------------------------+------+-------+
-- Aggregate and subquery forms stay on the legacy fallback source path.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') sum(rate(fused_multi_standalone[5s]));
+---------------------+---------------------------------------------+
| ts | sum(prom_rate(ts_range,val,ts,Int64(5000))) |
+---------------------+---------------------------------------------+
| 1970-01-01T00:00:04 | 33.0 |
+---------------------+---------------------------------------------+
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') rate(fused_multi_standalone[5s:1s]);
+---------------------+----------------------------------------+------+-------+
| ts | prom_rate(ts_range,val,ts,Int64(5000)) | host | kind |
+---------------------+----------------------------------------+------+-------+
| 1970-01-01T00:00:04 | 1.0 | h1 | left |
| 1970-01-01T00:00:04 | 10.0 | h1 | right |
| 1970-01-01T00:00:04 | 2.0 | h2 | left |
| 1970-01-01T00:00:04 | 20.0 | h2 | right |
+---------------------+----------------------------------------+------+-------+
DROP TABLE fused_multi_standalone;
Affected Rows: 0
@@ -0,0 +1,55 @@
-- SQL semantic regression; actual native routing and multi-partition execution verified separately over HTTP.
-- One insert and one flush keep the fixture small; this runner does not prove scan partitioning.
-- Four series, one sample per second. Instant selectors below evaluate at 4s, so their last values
-- are h1/left 5, h1/right 50, h2/left 10, h2/right 100.
CREATE TABLE fused_multi_standalone (
host STRING,
kind STRING,
ts TIMESTAMP(3) TIME INDEX,
val DOUBLE,
PRIMARY KEY (host, kind),
);
INSERT INTO fused_multi_standalone VALUES
('h1', 'left', 0, 1), ('h1', 'right', 0, 10), ('h2', 'left', 0, 2), ('h2', 'right', 0, 20),
('h1', 'left', 1000, 2), ('h1', 'right', 1000, 20), ('h2', 'left', 1000, 4), ('h2', 'right', 1000, 40),
('h1', 'left', 2000, 3), ('h1', 'right', 2000, 30), ('h2', 'left', 2000, 6), ('h2', 'right', 2000, 60),
('h1', 'left', 3000, 4), ('h1', 'right', 3000, 40), ('h2', 'left', 3000, 8), ('h2', 'right', 3000, 80),
('h1', 'left', 4000, 5), ('h1', 'right', 4000, 50), ('h2', 'left', 4000, 10), ('h2', 'right', 4000, 100);
ADMIN FLUSH_TABLE('fused_multi_standalone');
-- Both occurrences are the same full-key selector, combined by default matching addition.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} + fused_multi_standalone{host!="",kind!=""};
-- Subtraction is order sensitive: each series must be minus its own last value.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} - (fused_multi_standalone{host!="",kind!=""} * 2);
-- The same two selectors, added with an explicit full-key join.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} + on(host, kind) fused_multi_standalone{host!="",kind!=""};
-- Equality with bool keeps all four series and reports 1 for each.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{host!="",kind!=""} == bool fused_multi_standalone{host!="",kind!=""};
-- Different matchers cannot share one fused scan; on(host) keeps host: h1 55 and h2 110.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{kind="left"} + on(host) fused_multi_standalone{kind="right"};
-- group_right keeps the right-side kind: h1/left 10 and h1/right 55.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') fused_multi_standalone{kind="left",host="h1"} + on(host) group_right fused_multi_standalone{host="h1"};
-- Raw-table anchor: @ 3 with offset 1s ends the 3s window at 2s, although evaluation is at 4s.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') rate(fused_multi_standalone[3s] @ 3 offset 1s);
-- Aggregate and subquery forms stay on the legacy fallback source path.
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') sum(rate(fused_multi_standalone[5s]));
-- SQLNESS SORT_RESULT 3 1
TQL EVAL (4, 4, '1s') rate(fused_multi_standalone[5s:1s]);
DROP TABLE fused_multi_standalone;