未验证 提交 88217d2b 编写于 作者: S shenglian-zhou 提交者: GitHub

Merge pull request #11867 from taosdata/fix/td-14763

fix: csum from subquery supertable on state_window is not allowed, just as diff
......@@ -1286,6 +1286,17 @@ static int32_t validateStateWindowNode(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, SS
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);
}
size_t size = tscNumOfExprs(pQueryInfo);
for (int32_t i = 0; i < size; ++i) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
assert(pExpr != NULL);
int32_t functionId = pExpr->base.functionId;
if (functionId == TSDB_FUNC_CSUM || functionId == TSDB_FUNC_MAVG) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);
}
}
tscColumnListInsert(pQueryInfo->colList, index.columnIndex, pTableMeta->id.uid, pSchema);
SColIndex colIndex = { .colIndex = index.columnIndex, .flag = TSDB_COL_NORMAL, .colId = pSchema->colId };
taosArrayPush(pGroupExpr->columnInfo, &colIndex);
......@@ -7648,8 +7659,8 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQu
int32_t f = pExpr->base.functionId;
if ((f == TSDB_FUNC_PRJ && pExpr->base.numOfParams == 0) ||
f == TSDB_FUNC_DIFF || f == TSDB_FUNC_SCALAR_EXPR || f == TSDB_FUNC_DERIVATIVE ||
f == TSDB_FUNC_CSUM || f == TSDB_FUNC_MAVG || f == TSDB_FUNC_STATE_COUNT ||
f == TSDB_FUNC_STATE_DURATION)
f == TSDB_FUNC_CSUM || f == TSDB_FUNC_MAVG ||
f == TSDB_FUNC_STATE_COUNT || f == TSDB_FUNC_STATE_DURATION)
{
isProjectionFunction = true;
break;
......@@ -8649,8 +8660,13 @@ int32_t validateFunctionFromUpstream(SQueryInfo* pQueryInfo, char* msg) {
SExprInfo* pExpr = tscExprGet(pQueryInfo, i);
int32_t f = pExpr->base.functionId;
if (f == TSDB_FUNC_DERIVATIVE || f == TSDB_FUNC_TWA || f == TSDB_FUNC_IRATE || f == TSDB_FUNC_DIFF || f == TSDB_FUNC_ELAPSED ||
f == TSDB_FUNC_STATE_COUNT || f == TSDB_FUNC_STATE_DURATION) {
if (f == TSDB_FUNC_DERIVATIVE ||
f == TSDB_FUNC_TWA ||
f == TSDB_FUNC_IRATE ||
f == TSDB_FUNC_DIFF ||
f == TSDB_FUNC_ELAPSED ||
f == TSDB_FUNC_STATE_COUNT ||
f == TSDB_FUNC_STATE_DURATION) {
for (int32_t j = 0; j < upNum; ++j) {
SQueryInfo* pUp = taosArrayGetP(pQueryInfo->pUpstream, j);
STableMetaInfo *pTableMetaInfo = tscGetMetaInfo(pUp, 0);
......
import sys
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import tdDnodes
from math import inf
class TDTestCase:
def caseDescription(self):
'''
case1<shenglian zhou>: [TD-14763]csum can not be used on state window
'''
return
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self._conn = conn
def run(self):
print("running {}".format(__file__))
tdSql.execute("drop database if exists td14763")
tdSql.execute("create database td14763")
tdSql.execute("use td14763")
tdSql.execute("create table st ( ts timestamp, i int, b bool) tags (t1 int)")
tdSql.execute("create table ct1 using st tags(1)")
tdSql.execute("create table ct2 using st tags(2)")
for i in range(0, 4000, 2):
b = True if i%3 == 0 else False
tdSql.execute("insert into ct1 values(now + {}a, {}, {})".format(i, i, b))
tdSql.execute("insert into ct2 values(now + {}a, {}, {})".format(i+1, i+1, b))
tdSql.error("select csum(i) from ct1 state_window(b)")
tdSql.error("select csum(i) from (select * from st) state_window(b)")
tdSql.query("select csum(i) from ct1");
tdSql.execute('drop database td14763')
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
......@@ -638,6 +638,7 @@
6,,pytest,python3 test.py -f alter/alterColMultiTimes.py
6,,develop-test,python3 ./test.py -f 2-query/ts_2016.py
6,,develop-test,python3 ./test.py -f 2-query/escape.py
6,,develop-test,python3 ./test.py -f 2-query/TD-14763.py
5,,system-test,python3 ./test.py -f 4-taosAdapter/taosAdapter_insert.py
5,,system-test,python3 ./test.py -f 2-query/TD-12340-12342.py
5,,system-test,python3 ./test.py -f 2-query/TD-12276.py
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册