coverage: sum add all types test
This commit is contained in:
parent
ed1a3d6ab3
commit
df40772e95
|
@ -832,6 +832,7 @@ int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t rowIndex) {
|
int32_t setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t rowIndex) {
|
||||||
if (pCtx->subsidiaries.num <= 0) {
|
if (pCtx->subsidiaries.num <= 0) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -847,6 +848,7 @@ int32_t setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, int32_t rowIndex) {
|
int32_t setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, int32_t rowIndex) {
|
||||||
if (pCtx->subsidiaries.num <= 0) {
|
if (pCtx->subsidiaries.num <= 0) {
|
||||||
|
|
|
@ -28,7 +28,9 @@ from frame import *
|
||||||
|
|
||||||
|
|
||||||
class TDTestCase(TBase):
|
class TDTestCase(TBase):
|
||||||
|
updatecfgDict = {
|
||||||
|
"countAlwaysReturnValue" : "0"
|
||||||
|
}
|
||||||
|
|
||||||
def insertData(self):
|
def insertData(self):
|
||||||
tdLog.info(f"insert data.")
|
tdLog.info(f"insert data.")
|
||||||
|
@ -42,6 +44,10 @@ class TDTestCase(TBase):
|
||||||
self.insert_rows = 100000
|
self.insert_rows = 100000
|
||||||
self.timestamp_step = 10000
|
self.timestamp_step = 10000
|
||||||
|
|
||||||
|
# create count check table
|
||||||
|
sql = f"create table {self.db}.ta(ts timestamp, age int) tags(area int)"
|
||||||
|
tdSql.execute(sql)
|
||||||
|
|
||||||
def doAction(self):
|
def doAction(self):
|
||||||
tdLog.info(f"do action.")
|
tdLog.info(f"do action.")
|
||||||
self.flushDb()
|
self.flushDb()
|
||||||
|
@ -64,6 +70,9 @@ class TDTestCase(TBase):
|
||||||
selid = random.choice(vgids)
|
selid = random.choice(vgids)
|
||||||
self.balanceVGroupLeaderOn(selid)
|
self.balanceVGroupLeaderOn(selid)
|
||||||
|
|
||||||
|
# check count always return value
|
||||||
|
sql = f"select count(*) from {self.db}.ta"
|
||||||
|
tdSql.waitedQuery(sql, 0, 2)
|
||||||
|
|
||||||
|
|
||||||
# run
|
# run
|
||||||
|
|
|
@ -14,11 +14,12 @@ import time
|
||||||
# Auto Gen class
|
# Auto Gen class
|
||||||
#
|
#
|
||||||
class AutoGen:
|
class AutoGen:
|
||||||
def __init__(self):
|
def __init__(self, fillOne=False):
|
||||||
self.ts = 1600000000000
|
self.ts = 1600000000000
|
||||||
self.batch_size = 100
|
self.batch_size = 100
|
||||||
seed = time.time() % 10000
|
seed = time.time() % 10000
|
||||||
random.seed(seed)
|
random.seed(seed)
|
||||||
|
self.fillOne = fillOne
|
||||||
|
|
||||||
# set start ts
|
# set start ts
|
||||||
def set_start_ts(self, ts):
|
def set_start_ts(self, ts):
|
||||||
|
@ -87,6 +88,23 @@ class AutoGen:
|
||||||
|
|
||||||
return datas
|
return datas
|
||||||
|
|
||||||
|
# fill one data
|
||||||
|
def fillone_data(self, i, marr):
|
||||||
|
datas = ""
|
||||||
|
for c in marr:
|
||||||
|
if datas != "":
|
||||||
|
datas += ","
|
||||||
|
|
||||||
|
if c == 0:
|
||||||
|
datas += "%d" % (self.ts + i)
|
||||||
|
elif c == 12 or c == 13: # binary
|
||||||
|
datas += '"1"'
|
||||||
|
else:
|
||||||
|
datas += '1'
|
||||||
|
|
||||||
|
return datas
|
||||||
|
|
||||||
|
|
||||||
# generate specail wide random string
|
# generate specail wide random string
|
||||||
def random_string(self, count):
|
def random_string(self, count):
|
||||||
letters = string.ascii_letters
|
letters = string.ascii_letters
|
||||||
|
@ -127,6 +145,9 @@ class AutoGen:
|
||||||
|
|
||||||
# loop do
|
# loop do
|
||||||
for i in range(cnt):
|
for i in range(cnt):
|
||||||
|
if self.fillOne :
|
||||||
|
value = self.fillone_data(i, self.mcols)
|
||||||
|
else:
|
||||||
value = self.gen_data(i, self.mcols)
|
value = self.gen_data(i, self.mcols)
|
||||||
ts += step
|
ts += step
|
||||||
values += f"({ts},{value}) "
|
values += f"({ts},{value}) "
|
||||||
|
|
|
@ -14,11 +14,12 @@ import time
|
||||||
# Auto Gen class
|
# Auto Gen class
|
||||||
#
|
#
|
||||||
class AutoGen:
|
class AutoGen:
|
||||||
def __init__(self):
|
def __init__(self, fillOne=False):
|
||||||
self.ts = 1600000000000
|
self.ts = 1600000000000
|
||||||
self.batch_size = 100
|
self.batch_size = 100
|
||||||
seed = time.time() % 10000
|
seed = time.time() % 10000
|
||||||
random.seed(seed)
|
random.seed(seed)
|
||||||
|
self.fillOne = fillOne
|
||||||
|
|
||||||
# set start ts
|
# set start ts
|
||||||
def set_start_ts(self, ts):
|
def set_start_ts(self, ts):
|
||||||
|
@ -87,6 +88,23 @@ class AutoGen:
|
||||||
|
|
||||||
return datas
|
return datas
|
||||||
|
|
||||||
|
# fill one data
|
||||||
|
def fillone_data(self, i, marr):
|
||||||
|
datas = ""
|
||||||
|
for c in marr:
|
||||||
|
if datas != "":
|
||||||
|
datas += ","
|
||||||
|
|
||||||
|
if c == 0:
|
||||||
|
datas += "%d" % (self.ts + i)
|
||||||
|
elif c == 12 or c == 13: # binary
|
||||||
|
datas += '"1"'
|
||||||
|
else:
|
||||||
|
datas += '1'
|
||||||
|
|
||||||
|
return datas
|
||||||
|
|
||||||
|
|
||||||
# generate specail wide random string
|
# generate specail wide random string
|
||||||
def random_string(self, count):
|
def random_string(self, count):
|
||||||
letters = string.ascii_letters
|
letters = string.ascii_letters
|
||||||
|
@ -127,6 +145,9 @@ class AutoGen:
|
||||||
|
|
||||||
# loop do
|
# loop do
|
||||||
for i in range(cnt):
|
for i in range(cnt):
|
||||||
|
if self.fillOne :
|
||||||
|
value = self.fillone_data(i, self.mcols)
|
||||||
|
else:
|
||||||
value = self.gen_data(i, self.mcols)
|
value = self.gen_data(i, self.mcols)
|
||||||
ts += step
|
ts += step
|
||||||
values += f"({ts},{value}) "
|
values += f"({ts},{value}) "
|
||||||
|
|
|
@ -2,6 +2,7 @@ from util.log import *
|
||||||
from util.sql import *
|
from util.sql import *
|
||||||
from util.cases import *
|
from util.cases import *
|
||||||
from util.dnodes import *
|
from util.dnodes import *
|
||||||
|
from util.autogen import *
|
||||||
|
|
||||||
|
|
||||||
INT_COL = "c1"
|
INT_COL = "c1"
|
||||||
|
@ -23,11 +24,11 @@ TS_TYPE_COL = [TS_COL]
|
||||||
DBNAME = "db"
|
DBNAME = "db"
|
||||||
|
|
||||||
class TDTestCase:
|
class TDTestCase:
|
||||||
|
|
||||||
def init(self, conn, logSql, replicaVar=1):
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
self.replicaVar = int(replicaVar)
|
self.replicaVar = int(replicaVar)
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor())
|
tdSql.init(conn.cursor())
|
||||||
|
self.autoGen = AutoGen(True)
|
||||||
|
|
||||||
def __sum_condition(self):
|
def __sum_condition(self):
|
||||||
sum_condition = []
|
sum_condition = []
|
||||||
|
@ -207,9 +208,46 @@ class TDTestCase:
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def testAllTypes(self):
|
||||||
|
# create stable and insert
|
||||||
|
tdLog.info("test all types")
|
||||||
|
stbname = "stb"
|
||||||
|
colnum = 16
|
||||||
|
self.autoGen.set_batch_size(1000)
|
||||||
|
self.autoGen.create_stable(stbname, 16, colnum, 8, 16)
|
||||||
|
self.autoGen.create_child(stbname, "d", 4)
|
||||||
|
self.autoGen.insert_data(10000)
|
||||||
|
|
||||||
|
# check correct
|
||||||
|
i = 0
|
||||||
|
for c in self.autoGen.mcols:
|
||||||
|
|
||||||
|
if c in [0, 11, 12, 13]:
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
# query
|
||||||
|
col = f"c{i}"
|
||||||
|
sql = f"select count({col}), sum({col}), avg({col}), max({col}), min({col}) from stb"
|
||||||
|
tdSql.query(sql)
|
||||||
|
# sum
|
||||||
|
tdSql.checkData(0, 0, 4*10000, True)
|
||||||
|
# sum
|
||||||
|
tdSql.checkData(0, 1, 4*10000, True)
|
||||||
|
# avg
|
||||||
|
tdSql.checkData(0, 2, 1, True)
|
||||||
|
# max
|
||||||
|
tdSql.checkData(0, 3, 1, True)
|
||||||
|
# min
|
||||||
|
tdSql.checkData(0, 4, 1, True)
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
tdSql.prepare()
|
tdSql.prepare()
|
||||||
|
|
||||||
|
self.testAllTypes()
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step1:create table")
|
tdLog.printNoPrefix("==========step1:create table")
|
||||||
self.__create_tb()
|
self.__create_tb()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue