forbid tsma agg funcs with tag columns
This commit is contained in:
parent
1b37ef03fb
commit
039939196a
|
@ -557,6 +557,9 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
|
|||
if (cfgAddBool(pCfg, "multiResultFunctionStarReturnTags", tsMultiResultFunctionStarReturnTags, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, CFG_SCOPE_BOTH, CFG_DYN_CLIENT) != 0)
|
||||
return -1;
|
||||
if (cfgAddInt32(pCfg, "maxTsmaCalcDelay", tsMaxTsmaCalcDelay, 600, 86400, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) !=
|
||||
0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -734,7 +737,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddInt32(pCfg, "tmqRowSize", tmqRowSize, 1, 1000000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0)
|
||||
return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "tsMaxTsmaNum", tsMaxTsmaNum, 0, 12, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "maxTsmaNum", tsMaxTsmaNum, 0, 12, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "transPullupInterval", tsTransPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) !=
|
||||
0)
|
||||
return -1;
|
||||
|
@ -1206,7 +1209,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
|
||||
tmqMaxTopicNum = cfgGetItem(pCfg, "tmqMaxTopicNum")->i32;
|
||||
tmqRowSize = cfgGetItem(pCfg, "tmqRowSize")->i32;
|
||||
tsMaxTsmaNum = cfgGetItem(pCfg, "tsMaxTsmaNum")->i32;
|
||||
tsMaxTsmaNum = cfgGetItem(pCfg, "maxTsmaNum")->i32;
|
||||
tsMaxTsmaCalcDelay = cfgGetItem(pCfg, "maxTsmaCalcDelay")->i32;
|
||||
|
||||
tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32;
|
||||
tsCompactPullupInterval = cfgGetItem(pCfg, "compactPullupInterval")->i32;
|
||||
|
@ -1771,7 +1775,8 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, char *name) {
|
|||
{"slowLogThreshold", &tsSlowLogThreshold},
|
||||
{"useAdapter", &tsUseAdapter},
|
||||
{"experimental", &tsExperimental},
|
||||
{"multiResultFunctionStarReturnTags", &tsMultiResultFunctionStarReturnTags} };
|
||||
{"multiResultFunctionStarReturnTags", &tsMultiResultFunctionStarReturnTags},
|
||||
{"maxTsmaCalcDelay", &tsMaxTsmaCalcDelay}};
|
||||
|
||||
if (taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true) != 0) {
|
||||
taosCfgSetOption(options, tListLen(options), pItem, false);
|
||||
|
|
|
@ -1684,7 +1684,7 @@ static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq) {
|
|||
pStream = mndAcquireStream(pMnode, streamName);
|
||||
if (pStream != NULL) {
|
||||
mError("tsma:%s, failed to create since stream:%s already exist", createReq.name, streamName);
|
||||
terrno = TSDB_CODE_MND_STREAM_ALREADY_EXIST;
|
||||
terrno = TSDB_CODE_MND_SMA_ALREADY_EXIST;
|
||||
goto _OVER;
|
||||
}
|
||||
|
||||
|
@ -1959,9 +1959,9 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
|
||||
// create sql
|
||||
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
|
||||
char buf[TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
len = snprintf(buf + VARSTR_HEADER_SIZE, TSDB_SHOW_SQL_LEN, "%s", pSma->sql);
|
||||
varDataSetLen(buf, TMIN(len, TSDB_SHOW_SQL_LEN));
|
||||
char buf[TSDB_MAX_SAVED_SQL_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||
len = snprintf(buf + VARSTR_HEADER_SIZE, TSDB_MAX_SAVED_SQL_LEN, "%s", pSma->sql);
|
||||
varDataSetLen(buf, TMIN(len, TSDB_MAX_SAVED_SQL_LEN));
|
||||
colDataSetVal(pColInfo, numOfRows, buf, false);
|
||||
|
||||
// func list
|
||||
|
@ -1974,10 +1974,10 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
|
|||
if (nodeType(pFunc) == QUERY_NODE_FUNCTION) {
|
||||
SFunctionNode *pFuncNode = (SFunctionNode *)pFunc;
|
||||
if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue;
|
||||
len += snprintf(start, TSDB_SHOW_SQL_LEN - len, "%s%s", start != buf + VARSTR_HEADER_SIZE ? "," : "",
|
||||
len += snprintf(start, TSDB_MAX_SAVED_SQL_LEN - len, "%s%s", start != buf + VARSTR_HEADER_SIZE ? "," : "",
|
||||
((SExprNode *)pFunc)->userAlias);
|
||||
if (len >= TSDB_SHOW_SQL_LEN) {
|
||||
len = TSDB_SHOW_SQL_LEN;
|
||||
if (len >= TSDB_MAX_SAVED_SQL_LEN) {
|
||||
len = TSDB_MAX_SAVED_SQL_LEN;
|
||||
break;
|
||||
}
|
||||
start = buf + VARSTR_HEADER_SIZE + len;
|
||||
|
|
|
@ -10730,13 +10730,19 @@ static int32_t rewriteTSMAFuncs(STranslateContext* pCxt, SCreateTSMAStmt* pStmt,
|
|||
break;
|
||||
}
|
||||
SColumnNode* pCol = (SColumnNode*)pFunc->pParameterList->pHead->pNode;
|
||||
for (int32_t i = 0; i < columnNum; ++i) {
|
||||
int32_t i = 0;
|
||||
for (; i < columnNum; ++i) {
|
||||
if (strcmp(pCols[i].name, pCol->colName) == 0) {
|
||||
pCol->colId = pCols[i].colId;
|
||||
pCol->node.resType.type = pCols[i].type;
|
||||
pCol->node.resType.bytes = pCols[i].bytes;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == columnNum) {
|
||||
code = TSDB_CODE_TSMA_INVALID_FUNC_PARAM;
|
||||
break;
|
||||
}
|
||||
code = fmGetFuncInfo(pFunc, NULL, 0);
|
||||
if (TSDB_CODE_SUCCESS != code) break;
|
||||
if (!fmIsTSMASupportedFunc(pFunc->funcId)) {
|
||||
|
|
|
@ -691,7 +691,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_PTR, "Invalid tsma pointe
|
|||
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_PARA, "Invalid tsma parameters")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_TB, "Invalid table to create tsma, only stable or normal table allowed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_INTERVAL, "Invalid tsma interval, 1ms ~ 1h is allowed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_FUNC_PARAM, "Invalid tsma func param, only one column allowed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_FUNC_PARAM, "Invalid tsma func param, only one non-tag column allowed")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_UNSUPPORTED_FUNC, "Tsma func not supported")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_MUST_BE_DROPPED, "Tsma must be dropped first")
|
||||
TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_NAME_TOO_LONG, "Tsma name too long")
|
||||
|
|
|
@ -601,7 +601,7 @@ class TSMATestSQLGenerator:
|
|||
|
||||
|
||||
class TDTestCase:
|
||||
updatecfgDict = {'debugFlag': 143, 'asynclog': 0, 'ttlUnit': 1, 'ttlPushInterval': 5, 'ratioOfVnodeStreamThrea': 4}
|
||||
updatecfgDict = {'debugFlag': 143, 'asynclog': 0, 'ttlUnit': 1, 'ttlPushInterval': 5, 'ratioOfVnodeStreamThrea': 4, 'maxTsmaNum': 8}
|
||||
|
||||
def __init__(self):
|
||||
self.vgroups = 4
|
||||
|
@ -1323,6 +1323,9 @@ class TDTestCase:
|
|||
tdSql.error(
|
||||
'create tsma tsma1 on meters function(avg(c1), avg(c2)) interval(10m)', -2147482496)
|
||||
|
||||
# tsma already exists: test.tsma1
|
||||
tdSql.error('create tsma tsma1 on nsdb.meters function(avg(c1)) interval(10m)', -2147482496)
|
||||
|
||||
# max tsma num 8
|
||||
self.create_tsma('tsma2', 'nsdb', 'meters', ['avg(c1)', 'avg(c2)'], '10s')
|
||||
self.create_tsma('tsma3', 'nsdb', 'meters', ['avg(c1)', 'avg(c2)'], '100s')
|
||||
|
@ -1344,6 +1347,8 @@ class TDTestCase:
|
|||
|
||||
tdSql.error(
|
||||
'create tsma tsma1 on test.meters function(avg(c1), avg(c2)) interval(2h)', -2147471097)
|
||||
# only non-tag columns are allowed
|
||||
tdSql.error('create tsma tsma1 on test.meters function(avg(c1), avg(t6)) interval(10m)', -2147471096)
|
||||
tdSql.execute('drop database nsdb')
|
||||
|
||||
def test_create_tsma_on_norm_table(self):
|
||||
|
|
Loading…
Reference in New Issue