chore: test case for rollup
This commit is contained in:
parent
4097b53bfa
commit
2ad3b98344
|
@ -5163,21 +5163,20 @@ static int32_t checkTableColsSchema(STranslateContext* pCxt, SHashObj* pHash, in
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
bool first = true;
|
int32_t colIndex = 0;
|
||||||
bool isCalcRollup = false;
|
bool isCalcRollup = false;
|
||||||
int32_t rowSize = 0;
|
int32_t rowSize = 0;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
char* pFunc = NULL;
|
char* pFunc = NULL;
|
||||||
|
|
||||||
// if (pRollupFuncs) {
|
if (pRollupFuncs) {
|
||||||
// pFunc = ((SFunctionNode*)nodesListGetNode(pRollupFuncs, 0))->functionName;
|
pFunc = ((SFunctionNode*)nodesListGetNode(pRollupFuncs, 0))->functionName;
|
||||||
// isCalcRollup = caclRollupFunc(pFunc);
|
isCalcRollup = caclRollupFunc(pFunc);
|
||||||
// }
|
}
|
||||||
|
|
||||||
FOREACH(pNode, pCols) {
|
FOREACH(pNode, pCols) {
|
||||||
SColumnDefNode* pCol = (SColumnDefNode*)pNode;
|
SColumnDefNode* pCol = (SColumnDefNode*)pNode;
|
||||||
if (first) {
|
if (0 == colIndex) {
|
||||||
first = false;
|
|
||||||
if (TSDB_DATA_TYPE_TIMESTAMP != pCol->dataType.type) {
|
if (TSDB_DATA_TYPE_TIMESTAMP != pCol->dataType.type) {
|
||||||
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FIRST_COLUMN);
|
code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FIRST_COLUMN);
|
||||||
}
|
}
|
||||||
|
@ -5198,13 +5197,13 @@ static int32_t checkTableColsSchema(STranslateContext* pCxt, SHashObj* pHash, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (TSDB_CODE_SUCCESS == code && isCalcRollup) {
|
if (TSDB_CODE_SUCCESS == code && isCalcRollup && 0 != colIndex) {
|
||||||
// if (pCol->dataType.type != TSDB_DATA_TYPE_FLOAT && pCol->dataType.type != TSDB_DATA_TYPE_DOUBLE) {
|
if (pCol->dataType.type != TSDB_DATA_TYPE_FLOAT && pCol->dataType.type != TSDB_DATA_TYPE_DOUBLE) {
|
||||||
// code =
|
code =
|
||||||
// generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN,
|
generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN,
|
||||||
// "Invalid column type: %s, only float/double allowed for %s", pCol->colName, pFunc);
|
"Invalid column type: %s, only float/double allowed for %s", pCol->colName, pFunc);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = taosHashPut(pHash, pCol->colName, len, &pCol, POINTER_BYTES);
|
code = taosHashPut(pHash, pCol->colName, len, &pCol, POINTER_BYTES);
|
||||||
|
@ -5214,6 +5213,8 @@ static int32_t checkTableColsSchema(STranslateContext* pCxt, SHashObj* pHash, in
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++colIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code && rowSize > TSDB_MAX_BYTES_PER_ROW) {
|
if (TSDB_CODE_SUCCESS == code && rowSize > TSDB_MAX_BYTES_PER_ROW) {
|
||||||
|
|
|
@ -119,6 +119,16 @@ class TDTestCase:
|
||||||
f"create stable {dbname}.stb24 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) " ,
|
f"create stable {dbname}.stb24 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) " ,
|
||||||
f"create stable {dbname}.stb25 ({PRIMARY_COL} timestamp, {INT_COL} int) " ,
|
f"create stable {dbname}.stb25 ({PRIMARY_COL} timestamp, {INT_COL} int) " ,
|
||||||
f"create stable {dbname}.stb26 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) " ,
|
f"create stable {dbname}.stb26 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) " ,
|
||||||
|
# only float/double allowd for avg/sum
|
||||||
|
f"create stable {dbname}.stb11 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(avg)",
|
||||||
|
f"create stable {dbname}.stb11 ({PRIMARY_COL} timestamp, {BINT_COL} bigint) tags (tag1 int) rollup(avg)",
|
||||||
|
f"create stable {dbname}.stb11 ({PRIMARY_COL} timestamp, {BOOL_COL} bool) tags (tag1 int) rollup(avg)",
|
||||||
|
f"create stable {dbname}.stb11 ({PRIMARY_COL} timestamp, {BINARY_COL} binary(10)) tags (tag1 int) rollup(avg)",
|
||||||
|
f"create stable {dbname}.stb11 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(sum)",
|
||||||
|
f"create stable {dbname}.stb11 ({PRIMARY_COL} timestamp, {BINT_COL} bigint) tags (tag1 int) rollup(sum)",
|
||||||
|
f"create stable {dbname}.stb11 ({PRIMARY_COL} timestamp, {BOOL_COL} bool) tags (tag1 int) rollup(sum)",
|
||||||
|
f"create stable {dbname}.stb11 ({PRIMARY_COL} timestamp, {BINARY_COL} binary(10)) tags (tag1 int) rollup(sum)",
|
||||||
|
|
||||||
|
|
||||||
# watermark, max_delay: [0, 900000], [ms, s, m, ?]
|
# watermark, max_delay: [0, 900000], [ms, s, m, ?]
|
||||||
f"create stable stb17 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1u",
|
f"create stable stb17 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1u",
|
||||||
|
@ -135,10 +145,10 @@ class TDTestCase:
|
||||||
@property
|
@property
|
||||||
def create_stable_sql_current(self):
|
def create_stable_sql_current(self):
|
||||||
return [
|
return [
|
||||||
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(avg)",
|
f"create stable stb1 ({PRIMARY_COL} timestamp, {FLOAT_COL} float) tags (tag1 int) rollup(avg)",
|
||||||
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 5s max_delay 1m",
|
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 5s max_delay 1m",
|
||||||
f"create stable stb3 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(max) watermark 5s max_delay 1m",
|
f"create stable stb3 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(max) watermark 5s max_delay 1m",
|
||||||
f"create stable stb4 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(sum) watermark 5s max_delay 1m",
|
f"create stable stb4 ({PRIMARY_COL} timestamp, {DOUBLE_COL} double) tags (tag1 int) rollup(sum) watermark 5s max_delay 1m",
|
||||||
f"create stable stb5 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(last) watermark 5s max_delay 1m",
|
f"create stable stb5 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(last) watermark 5s max_delay 1m",
|
||||||
f"create stable stb6 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m",
|
f"create stable stb6 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m",
|
||||||
f"create stable stb7 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL})",
|
f"create stable stb7 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL})",
|
||||||
|
@ -181,6 +191,12 @@ class TDTestCase:
|
||||||
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned, {BINARY_COL} binary(16)
|
{INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned, {BINARY_COL} binary(16)
|
||||||
) tags ({INT_TAG} int) rollup({rsma_type}) watermark 5s,5s max_delay 5s,5s
|
) tags ({INT_TAG} int) rollup({rsma_type}) watermark 5s,5s max_delay 5s,5s
|
||||||
'''
|
'''
|
||||||
|
elif rsma_type.lower().strip() in ("sum", "avg"):
|
||||||
|
create_stb_sql = f'''create table {dbname}.{stb}(
|
||||||
|
ts timestamp, {DOUBLE_COL} double, {DOUBLE_COL}_1 double, {DOUBLE_COL}_2 double, {DOUBLE_COL}_3 double,
|
||||||
|
{FLOAT_COL} float, {DOUBLE_COL}_4 double, {FLOAT_COL}_1 float, {FLOAT_COL}_2 float, {FLOAT_COL}_3 float,
|
||||||
|
{DOUBLE_COL}_5 double) tags ({INT_TAG} int) rollup({rsma_type}) watermark 5s,5s max_delay 5s,5s
|
||||||
|
'''
|
||||||
else:
|
else:
|
||||||
create_stb_sql = f'''create table {dbname}.{stb}(
|
create_stb_sql = f'''create table {dbname}.{stb}(
|
||||||
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint,
|
||||||
|
@ -227,11 +243,16 @@ class TDTestCase:
|
||||||
{data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]},
|
{data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]},
|
||||||
{data.utint_data[i]}, {data.usint_data[i]}, {data.uint_data[i]}, {data.ubint_data[i]}, '{data.vchar_data[i]}'
|
{data.utint_data[i]}, {data.usint_data[i]}, {data.uint_data[i]}, {data.ubint_data[i]}, '{data.vchar_data[i]}'
|
||||||
'''
|
'''
|
||||||
else:
|
elif rsma_type.lower().strip() in ("sum", "avg"):
|
||||||
row_data = f'''
|
row_data = f'''
|
||||||
{data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]},
|
{data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]},
|
||||||
{data.utint_data[i]}, {data.usint_data[i]}, {data.uint_data[i]}, {data.ubint_data[i]}
|
{data.utint_data[i]}, {data.usint_data[i]}, {data.uint_data[i]}, {data.ubint_data[i]}
|
||||||
'''
|
'''
|
||||||
|
else:
|
||||||
|
row_data = f'''
|
||||||
|
{data.double_data[i]}, {data.double_data[i]}, {data.double_data[i]}, {data.double_data[i]}, {data.float_data[i]}, {data.double_data[i]},
|
||||||
|
{data.float_data[i]}, {data.float_data[i]}, {data.float_data[i]}, {data.double_data[i]}
|
||||||
|
'''
|
||||||
else:
|
else:
|
||||||
row_data = f'''
|
row_data = f'''
|
||||||
{data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]},
|
{data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]},
|
||||||
|
@ -272,17 +293,17 @@ class TDTestCase:
|
||||||
tdSql.query(f"select count(*) from {DB3}.{STBNAME} where ts > now()-5m")
|
tdSql.query(f"select count(*) from {DB3}.{STBNAME} where ts > now()-5m")
|
||||||
tdSql.checkData(0, 0, self.rows * db3_ctb_num)
|
tdSql.checkData(0, 0, self.rows * db3_ctb_num)
|
||||||
tdSql.checkRows(1)
|
tdSql.checkRows(1)
|
||||||
tdSql.query(f"select {INT_COL} from {DB3}.{CTBNAME} where ts > now()-4d")
|
tdSql.query(f"select {FLOAT_COL} from {DB3}.{CTBNAME} where ts > now()-4d")
|
||||||
# not stable
|
# not stable
|
||||||
#tdSql.checkData(0, 0, self.rows-1)
|
#tdSql.checkData(0, 0, self.rows-1)
|
||||||
tdSql.query(f"select {INT_COL} from {DB3}.{CTBNAME} where ts > now()-6d")
|
tdSql.query(f"select {DOUBLE_COL} from {DB3}.{CTBNAME} where ts > now()-6d")
|
||||||
# not stable
|
# not stable
|
||||||
# tdSql.checkData(0, 0, self.rows-1)
|
# tdSql.checkData(0, 0, self.rows-1)
|
||||||
|
|
||||||
# from ...pytest.util.sql import tdSql
|
# from ...pytest.util.sql import tdSql
|
||||||
|
|
||||||
tdLog.printNoPrefix("==========step2.1.1 : alter stb schemaL drop column")
|
tdLog.printNoPrefix("==========step2.1.1 : alter stb schemaL drop column")
|
||||||
tdSql.query(f"select {BINT_COL} from {DB3}.{STBNAME}")
|
tdSql.query(f"select {FLOAT_COL} from {DB3}.{STBNAME}")
|
||||||
#tdSql.execute(f"alter stable {DB3}.stb1 drop column {BINT_COL}")
|
#tdSql.execute(f"alter stable {DB3}.stb1 drop column {BINT_COL}")
|
||||||
# not support alter stable schema anymore
|
# not support alter stable schema anymore
|
||||||
tdSql.error(f"alter stable {DB3}.stb1 drop column {BINT_COL}")
|
tdSql.error(f"alter stable {DB3}.stb1 drop column {BINT_COL}")
|
||||||
|
|
Loading…
Reference in New Issue