未验证 提交 81281455 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #13773 from taosdata/fix/TD-14698-V26

test: add test case for TD-14678, TD-14698
......@@ -3034,23 +3034,42 @@ static bool overlapWithTimeWindow(SQueryAttr* pQueryAttr, SDataBlockInfo* pBlock
}
}
} else {
getAlignQueryTimeWindow(pQueryAttr, pBlockInfo->window.ekey, sk, ek, &w);
int64_t ekey = pBlockInfo->window.ekey;
getAlignQueryTimeWindow(pQueryAttr, ekey, sk, ek, &w);
assert(w.skey <= pBlockInfo->window.ekey);
if (w.skey > pBlockInfo->window.skey) {
return true;
}
while(w.skey < pBlockInfo->window.ekey) {
// add one slding
if (pQueryAttr->interval.slidingUnit == 'n' || pQueryAttr->interval.slidingUnit == 'y')
ekey = taosTimeAdd(ekey, pQueryAttr->interval.sliding, pQueryAttr->interval.slidingUnit, pQueryAttr->precision);
else
ekey += pQueryAttr->interval.sliding;
// not in range sk~ek, break
if (!(ekey >= sk && ekey <= ek)) {
break;
}
// get align
getAlignQueryTimeWindow(pQueryAttr, ekey, sk, ek, &w);
}
while(1) {
getNextTimeWindow(pQueryAttr, &w);
if (w.ekey < pBlockInfo->window.skey) {
break;
}
assert(w.skey < pBlockInfo->window.skey);
if (w.ekey < pBlockInfo->window.ekey && w.ekey >= pBlockInfo->window.skey) {
// window start point in block window range return true
if (w.skey >= pBlockInfo->window.skey && w.skey <= pBlockInfo->window.ekey) {
return true;
}
// window end point in block window ragne return true
if (w.ekey <= pBlockInfo->window.ekey && w.ekey >= pBlockInfo->window.skey) {
return true;
}
getNextTimeWindow(pQueryAttr, &w);
}
}
......@@ -6155,6 +6174,7 @@ SOperatorInfo *createOrderOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorI
goto _clean;
}
bool found = false;
for (int32_t i = 0; i < numOfOutput; ++i) {
SColumnInfoData col = {{0}};
col.info.colId = pExpr[i].base.colInfo.colId;
......@@ -6162,8 +6182,9 @@ SOperatorInfo *createOrderOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOperatorI
col.info.type = pExpr[i].base.resType;
taosArrayPush(pDataBlock->pDataBlock, &col);
if (col.info.colId == pOrderVal->orderColId) {
if (!found && col.info.colId == pOrderVal->orderColId) {
pInfo->colIndex = i;
found = true;
}
}
......
......@@ -13,6 +13,7 @@
import sys
import taos
import numpy as np
from util.log import tdLog
from util.cases import tdCases
from util.sql import tdSql
......@@ -162,6 +163,39 @@ class TDTestCase:
tdSql.error("select twa(c) from tb group by c")
# TD-14678
tdSql.execute("create database test4")
tdSql.execute("use test4")
tdSql.execute("create table stb(ts timestamp, c int) tags(t1 int)")
ts = 1630000000000
sql = "insert into t1 using stb tags(1) values"
for i in range(100):
sql += "(%d, %d)" % (ts + i * 1000, i % 100)
tdSql.execute(sql)
tdSql.query("select COUNT(*) from stb interval(13m) sliding(3m) group by tbname order by ts desc")
tdSql.checkData(0, 1, 20)
tdSql.checkData(1, 1, 100)
tdSql.checkData(2, 1, 100)
tdSql.checkData(3, 1, 100)
tdSql.checkData(4, 1, 100)
tdSql.query("select COUNT(*) from stb interval(13m) sliding(3m) group by tbname order by ts")
tdSql.checkData(0, 1, 100)
tdSql.checkData(1, 1, 100)
tdSql.checkData(2, 1, 100)
tdSql.checkData(3, 1, 100)
tdSql.checkData(4, 1, 20)
# TD-14698
tdSql.query("select SPREAD(_c0) from (select * from stb) where ts between 1630000001000 and 1630100001000 interval(12h) Fill(NULL) order by ts")
matrix = np.array(tdSql.queryResult)
list = matrix[:, 0]
if all(sorted(list) == list):
tdLog.info("sql:%s, column : ts is sorted in accending order as expected" % (tdSql.sql))
else:
tdLog.exit("sql:%s, column : ts is not sorted in accending order as expected" % (tdSql.sql))
def stop(self):
tdSql.close()
......
......@@ -121,6 +121,9 @@ class TDTestCase:
tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id")
tdSql.checkRows(6)
tdSql.query("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.id, stb_p.dscrption, stb_p.pressure from stb_p, stb_t where stb_p.ts=stb_t.ts and stb_p.id = stb_t.id order by ts desc limit 1 offset 1")
tdSql.checkRows(1)
tdSql.error("select stb_t.ts, stb_t.dscrption, stb_t.temperature, stb_t.pid, stb_p.id, stb_p.dscrption, stb_p.pressure,stb_v.velocity from stb_p, stb_t, stb_v where stb_p.ts=stb_t.ts and stb_p.ts=stb_v.ts and stb_p.id = stb_t.id")
# test case for https://jira.taosdata.com:18080/browse/TD-1250
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册