test for tsma
This commit is contained in:
parent
85beb0b441
commit
54666c953f
|
@ -6356,6 +6356,7 @@ static int32_t tsmaOptRevisePlan(STSMAOptCtx* pTsmaOptCtx, SLogicNode* pParent,
|
||||||
const STSMAOptUsefulTsma* pTsma) {
|
const STSMAOptUsefulTsma* pTsma) {
|
||||||
SNode * pStateFuncNode, *pAggFuncNode;
|
SNode * pStateFuncNode, *pAggFuncNode;
|
||||||
SColumnNode* pColNode;
|
SColumnNode* pColNode;
|
||||||
|
SListCell* pScanListCell = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SNodeList* pAggStateFuncs = NULL;
|
SNodeList* pAggStateFuncs = NULL;
|
||||||
SNodeList* pAggFuncs = NULL;
|
SNodeList* pAggFuncs = NULL;
|
||||||
|
@ -6378,6 +6379,7 @@ static int32_t tsmaOptRevisePlan(STSMAOptCtx* pTsmaOptCtx, SLogicNode* pParent,
|
||||||
code = fmCreateStateFuncs(pAggStateFuncs);
|
code = fmCreateStateFuncs(pAggStateFuncs);
|
||||||
if (code) return code;
|
if (code) return code;
|
||||||
|
|
||||||
|
pScanListCell = pScan->pScanCols->pHead;
|
||||||
FORBOTH(pStateFuncNode, pAggStateFuncs, pAggFuncNode, pAggFuncs) {
|
FORBOTH(pStateFuncNode, pAggStateFuncs, pAggFuncNode, pAggFuncs) {
|
||||||
SFunctionNode* pStateFunc = (SFunctionNode*)pStateFuncNode;
|
SFunctionNode* pStateFunc = (SFunctionNode*)pStateFuncNode;
|
||||||
SFunctionNode* pAggFunc = (SFunctionNode*)pAggFuncNode;
|
SFunctionNode* pAggFunc = (SFunctionNode*)pAggFuncNode;
|
||||||
|
@ -6391,11 +6393,12 @@ static int32_t tsmaOptRevisePlan(STSMAOptCtx* pTsmaOptCtx, SLogicNode* pParent,
|
||||||
REPLACE_LIST2_NODE(pAggFuncNode);
|
REPLACE_LIST2_NODE(pAggFuncNode);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
} else if (fmIsPseudoColumnFunc(pStateFunc->funcId)) {
|
} else if (fmIsPseudoColumnFunc(pAggFunc->funcId)) {
|
||||||
if (pStateFunc->funcType == FUNCTION_TYPE_WSTART) hasWStart = true;
|
if (pAggFunc->funcType == FUNCTION_TYPE_WSTART) hasWStart = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pColNode = (SColumnNode*)pScan->pScanCols->pHead->pNode;
|
pColNode = (SColumnNode*)pScanListCell->pNode;
|
||||||
|
pScanListCell = pScanListCell->pNext;
|
||||||
pColNode->node.resType = pStateFunc->node.resType;
|
pColNode->node.resType = pStateFunc->node.resType;
|
||||||
|
|
||||||
nodesDestroyList(pAggFunc->pParameterList);
|
nodesDestroyList(pAggFunc->pParameterList);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from random import randrange
|
||||||
import taos
|
import taos
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
@ -61,9 +62,9 @@ class TDTestCase:
|
||||||
sql += " %s%d values "%(ctbPrefix,i)
|
sql += " %s%d values "%(ctbPrefix,i)
|
||||||
for j in range(rowsPerTbl):
|
for j in range(rowsPerTbl):
|
||||||
if (i < ctbNum/2):
|
if (i < ctbNum/2):
|
||||||
sql += "(%d, %d, %d, %d,%d,%d,%d,true,'binary%d', 'nchar%d') "%(startTs + j*tsStep, j%10, j%10, j%10, j%10, j%10, j%10, j%10, j%10)
|
sql += "(%d, %d, %d, %d,%d,%d,%d,true,'binary%d', 'nchar%d') "%(startTs + j*tsStep + randrange(500), j%10, j%10, j%10, j%10, j%10, j%10, j%10, j%10)
|
||||||
else:
|
else:
|
||||||
sql += "(%d, %d, NULL, %d,NULL,%d,%d,true,'binary%d', 'nchar%d') "%(startTs + j*tsStep, j%10, j%10, j%10, j%10, j%10, j%10)
|
sql += "(%d, %d, NULL, %d,NULL,%d,%d,true,'binary%d', 'nchar%d') "%(startTs + j*tsStep + randrange(500), j%10, j%10, j%10, j%10, j%10, j%10)
|
||||||
rowsBatched += 1
|
rowsBatched += 1
|
||||||
if ((rowsBatched == batchNum) or (j == rowsPerTbl - 1)):
|
if ((rowsBatched == batchNum) or (j == rowsPerTbl - 1)):
|
||||||
tsql.execute(sql)
|
tsql.execute(sql)
|
||||||
|
@ -77,7 +78,7 @@ class TDTestCase:
|
||||||
tdLog.debug("insert data ............ [OK]")
|
tdLog.debug("insert data ............ [OK]")
|
||||||
return
|
return
|
||||||
|
|
||||||
def prepareTestEnv(self):
|
def init_data(self, ctb_num: int = 10, rows_per_ctb: int = 10000, start_ts : int = 1537146000000 , ts_step : int = 500):
|
||||||
tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ")
|
tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ")
|
||||||
paraDict = {'dbName': 'test',
|
paraDict = {'dbName': 'test',
|
||||||
'dropFlag': 1,
|
'dropFlag': 1,
|
||||||
|
@ -89,11 +90,11 @@ class TDTestCase:
|
||||||
'tagSchema': [{'type': 'INT', 'count':1},{'type': 'nchar', 'len':20, 'count':1},{'type': 'binary', 'len':20, 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'smallint', 'count':1},{'type': 'DOUBLE', 'count':1}],
|
'tagSchema': [{'type': 'INT', 'count':1},{'type': 'nchar', 'len':20, 'count':1},{'type': 'binary', 'len':20, 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'smallint', 'count':1},{'type': 'DOUBLE', 'count':1}],
|
||||||
'ctbPrefix': 't',
|
'ctbPrefix': 't',
|
||||||
'ctbStartIdx': 0,
|
'ctbStartIdx': 0,
|
||||||
'ctbNum': 100,
|
'ctbNum': ctb_num,
|
||||||
'rowsPerTbl': 10000,
|
'rowsPerTbl': rows_per_ctb,
|
||||||
'batchNum': 3000,
|
'batchNum': 3000,
|
||||||
'startTs': 1537146000000,
|
'startTs': start_ts,
|
||||||
'tsStep': 600000}
|
'tsStep': ts_step}
|
||||||
|
|
||||||
paraDict['vgroups'] = self.vgroups
|
paraDict['vgroups'] = self.vgroups
|
||||||
paraDict['ctbNum'] = self.ctbNum
|
paraDict['ctbNum'] = self.ctbNum
|
||||||
|
@ -115,8 +116,64 @@ class TDTestCase:
|
||||||
startTs=paraDict["startTs"],tsStep=paraDict["tsStep"])
|
startTs=paraDict["startTs"],tsStep=paraDict["tsStep"])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def create_tsma(self, tsma_name: str, db: str, tb: str, func_list: list, col_list: list, interval: str):
|
||||||
|
tdSql.execute('use %s' % db)
|
||||||
|
sql = "create tsma %s on %s.%s function(%s) column(%s) interval(%s)" % (tsma_name, db, tb, ','.join(func_list), ','.join(col_list), interval)
|
||||||
|
tdSql.execute(sql, queryTimes=1)
|
||||||
|
|
||||||
|
def drop_tsma(self, tsma_name: str, db: str):
|
||||||
|
sql = 'drop tsma %s.%s' % (db, tsma_name)
|
||||||
|
tdSql.execute(sql, queryTimes=1)
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma(self):
|
||||||
|
self.init_data()
|
||||||
|
self.create_tsma('tsma1', 'test', 'meters', ['avg'], ['c1', 'c2'], '5m')
|
||||||
|
self.create_tsma('tsma2', 'test', 'meters', ['avg'], ['c1', 'c2'], '30m')
|
||||||
|
self.test_explain_query_with_tsma_interval()
|
||||||
|
self.test_explain_query_with_tsma_agg()
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_interval(self):
|
||||||
|
self.test_explain_query_with_tsma_interval_no_partition()
|
||||||
|
self.test_explain_query_with_tsma_interval_partition_by_col()
|
||||||
|
self.test_explain_query_with_tsma_interval_partition_by_tbname()
|
||||||
|
self.test_explain_query_with_tsma_interval_partition_by_tag()
|
||||||
|
self.test_explain_query_with_tsma_interval_partition_by_hybrid()
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_interval_no_partition(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_interval_partition_by_tbname(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_interval_partition_by_tag(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_interval_partition_by_col(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_interval_partition_by_hybrid(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_agg(self):
|
||||||
|
self.test_explain_query_with_tsma_agg_no_group_by()
|
||||||
|
self.test_explain_query_with_tsma_agg_group_by_hybrid()
|
||||||
|
self.test_explain_query_with_tsma_agg_group_by_tbname()
|
||||||
|
self.test_explain_query_with_tsma_agg_group_by_tag()
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_agg_no_group_by(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_agg_group_by_tbname(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_agg_group_by_tag(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def test_explain_query_with_tsma_agg_group_by_hybrid(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.prepareTestEnv()
|
self.test_explain_query_with_tsma()
|
||||||
time.sleep(999999)
|
time.sleep(999999)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
Loading…
Reference in New Issue