rows window results are not reasonable
Bug Description
How can I confirm the current row position of my input?
10.97.152.110:6527/demo_db> desc test;
--- ----------- --------- ------ ---------
# Field Type Null Default
--- ----------- --------- ------ ---------
1 value Int YES
2 condition Bool YES
3 catagory Varchar YES
--- ----------- --------- ------ ---------
--- -------------------- ---------- ------- ------ ---------------
# name keys ts ttl ttl_type
--- -------------------- ---------- ------- ------ ---------------
1 INDEX_0_1663162138 value - 0min kAbsoluteTime
2 INDEX_1_1663162165 catagory value 2 kLatestTime
--- -------------------- ---------- ------- ------ ---------------
--------------
storage_mode
--------------
Memory
--------------
10.97.152.110:6527/demo_db> select * from test;
------- ----------- ----------
value condition catagory
------- ----------- ----------
7 true y
9 true y
8 true y
3 true y
1 true y
------- ----------- ----------
5 rows in set
10.97.152.110:6527/demo_db> show deployment ddd;
--------- ------------
DB Deployment
--------- ------------
demo_db ddd
--------- ------------
1 row in set
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DEPLOY ddd SELECT
value,
top(value, 3) OVER (w)
FROM
test
WINDOW w AS (PARTITION BY catagory
ORDER BY value ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
;
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 row in set
# Input Schema
--- ----------- --------- ------------
# Field Type IsConstant
--- ----------- --------- ------------
1 value Int32 NO
2 condition Bool NO
3 catagory Varchar NO
--- ----------- --------- ------------
# Output Schema
--- --------------------- --------- ------------
# Field Type IsConstant
--- --------------------- --------- ------------
1 value Int32 NO
2 top(value, 3)over w Varchar NO
--- --------------------- --------- ------------
request1:{"input":[[1,false,"y"]],"need_schema":true} response1:{"code":0,"msg":"ok","data":{"schema":[{"name":"value","type":"int32"},{"name":"top(value, 3)over w","type":"string"}],"data":[[1,"1"]]}}
request2:{"input":[[9,false,"y"]],"need_schema":true} response2:{"code":0,"msg":"ok","data":{"schema":[{"name":"value","type":"int32"},{"name":"top(value, 3)over w","type":"string"}],"data":[[9,"9,9,8"]]}}
request3:{"input":[[4,false,"y"]],"need_schema":true} response3:{"code":0,"msg":"ok","data":{"schema":[{"name":"value","type":"int32"},{"name":"top(value, 3)over w","type":"string"}],"data":[[4,"4"]]}}
5 rows in set
Expected Behavior
Steps to Reproduce
About request 1 and 3, we can reproduce by
create database db;
use db;
create table test(value int, condition bool, catagory string);
set @@execute_mode='online';
insert into test values(1, true, "y"),(3,true,"y"),(8,true,"y");
DEPLOY ddd SELECT
value,
top(value, 3) OVER (w),
count(*) OVER w
FROM
test
WINDOW w AS (PARTITION BY catagory
ORDER BY value ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW);
then
curl -X POST -d'{"input":[[10,false,"y"]],"need_schema":true}' http://127.0.0.1:9080/dbs/db/deployments/ddd
only get result [10,"10"], cuz window only has the request row(current row)
About request 1 and 3, we can reproduce by
create database db; use db; create table test(value int, condition bool, catagory string); set @@execute_mode='online'; insert into test values(1, true, "y"),(3,true,"y"),(8,true,"y"); DEPLOY ddd SELECT value, top(value, 3) OVER (w), count(*) OVER w FROM test WINDOW w AS (PARTITION BY catagory ORDER BY value ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW);then
curl -X POST -d'{"input":[[10,false,"y"]],"need_schema":true}' http://127.0.0.1:9080/dbs/db/deployments/dddonly get result[10,"10"], cuz window only has the request row(current row)
The new index(delployed) can't load the old data in old indexes. So we should do deploy before insert. I'll write it in doc.