From c49aa8e1f9fc7e20948a9ed651239dc1c1d79041 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Wed, 31 Aug 2022 18:51:29 +0800 Subject: [PATCH 1/4] fix(query): support timestap type in max/min function TD-16780 --- include/common/ttypes.h | 8 +++++--- source/libs/function/src/builtins.c | 20 ++++++++++++++++++-- source/libs/function/src/builtinsimpl.c | 8 ++++---- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/include/common/ttypes.h b/include/common/ttypes.h index ceb3eae033..a88f65f6ac 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -49,9 +49,6 @@ typedef struct { #define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v)) #define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE)) #define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len)) -#define IS_VAR_DATA_TYPE(t) \ - (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON)) -#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR)) #define varDataNetLen(v) (htons(((VarDataLenT *)(v))[0])) #define varDataNetTLen(v) (sizeof(VarDataLenT) + varDataNetLen(v)) @@ -268,11 +265,16 @@ typedef struct { #define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT) #define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE) #define IS_INTEGER_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t))) +#define IS_TIMESTAMP_TYPE(_t) ((_t) == TSDB_DATA_TYPE_TIMESTAMP) #define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t))) #define IS_MATHABLE_TYPE(_t) \ (IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP)) +#define IS_VAR_DATA_TYPE(t) \ + (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON)) +#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR)) + #define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX) #define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX) #define IS_VALID_INT(_t) ((_t) >= INT32_MIN && (_t) <= INT32_MAX) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index b7cd02befd..5f17129417 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -311,6 +311,22 @@ static int32_t translateInOutStr(SFunctionNode* pFunc, char* pErrBuf, int32_t le return TSDB_CODE_SUCCESS; } +static int32_t translateMinMax(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (!IS_TIMESTAMP_TYPE(paraType) && !IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } else if (IS_NULL_TYPE(paraType)) { + paraType = TSDB_DATA_TYPE_BIGINT; + } + + pFunc->node.resType = (SDataType){.bytes = tDataTypes[paraType].bytes, .type = paraType}; + return TSDB_CODE_SUCCESS; +} + static int32_t translateTrimStr(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isLtrim) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -2060,7 +2076,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "min", .type = FUNCTION_TYPE_MIN, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_SELECT_FUNC, - .translateFunc = translateInOutNum, + .translateFunc = translateMinMax, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minmaxFunctionSetup, @@ -2075,7 +2091,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "max", .type = FUNCTION_TYPE_MAX, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_SELECT_FUNC, - .translateFunc = translateInOutNum, + .translateFunc = translateMinMax, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minmaxFunctionSetup, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 32d0472a50..82625157a3 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -1202,7 +1202,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { doSaveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); } } else { - if (IS_SIGNED_NUMERIC_TYPE(type)) { + if (IS_SIGNED_NUMERIC_TYPE(type) || IS_TIMESTAMP_TYPE(type)) { int64_t prev = 0; GET_TYPED_DATA(prev, int64_t, type, &pBuf->v); @@ -1214,7 +1214,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { doSaveTupleData(pCtx, index, pCtx->pSrcBlock, &pBuf->tuplePos); } } - } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { uint64_t prev = 0; GET_TYPED_DATA(prev, uint64_t, type, &pBuf->v); @@ -1262,7 +1261,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { int32_t start = pInput->startRowIndex; int32_t numOfRows = pInput->numOfRows; - if (IS_SIGNED_NUMERIC_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) { + if (IS_SIGNED_NUMERIC_TYPE(type) || IS_TIMESTAMP_TYPE(type) || type == TSDB_DATA_TYPE_BOOL) { if (type == TSDB_DATA_TYPE_TINYINT || type == TSDB_DATA_TYPE_BOOL) { int8_t* pData = (int8_t*)pCol->pData; int8_t* val = (int8_t*)&pBuf->v; @@ -1356,7 +1355,8 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { numOfElems += 1; } - } else if (type == TSDB_DATA_TYPE_BIGINT) { + } else if (type == TSDB_DATA_TYPE_BIGINT || + type == TSDB_DATA_TYPE_TIMESTAMP) { int64_t* pData = (int64_t*)pCol->pData; int64_t* val = (int64_t*)&pBuf->v; From a34da949bce635e61cb71cedc6a8d028de1f5eaa Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Wed, 31 Aug 2022 18:51:29 +0800 Subject: [PATCH 2/4] fix(query): support timestap type in max/min function TD-16780 --- source/libs/function/src/builtins.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 5f17129417..648ae5a538 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -714,7 +714,7 @@ static int32_t translateSpread(SFunctionNode* pFunc, char* pErrBuf, int32_t len) } uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (!IS_NUMERIC_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_NUMERIC_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -729,7 +729,7 @@ static int32_t translateSpreadImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; if (isPartial) { - if (!IS_NUMERIC_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_NUMERIC_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } pFunc->node.resType = (SDataType){.bytes = getSpreadInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; @@ -804,7 +804,7 @@ static int32_t translateElapsedImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t } uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_TIMESTAMP_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -1650,7 +1650,7 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { uint8_t colType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; if (!IS_SIGNED_NUMERIC_TYPE(colType) && !IS_FLOAT_TYPE(colType) && TSDB_DATA_TYPE_BOOL != colType && - TSDB_DATA_TYPE_TIMESTAMP != colType) { + !IS_TIMESTAMP_TYPE(colType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -1676,7 +1676,7 @@ static int32_t translateDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { } uint8_t resType; - if (IS_SIGNED_NUMERIC_TYPE(colType) || TSDB_DATA_TYPE_BOOL == colType || TSDB_DATA_TYPE_TIMESTAMP == colType) { + if (IS_SIGNED_NUMERIC_TYPE(colType) || IS_TIMESTAMP_TYPE(colType) || TSDB_DATA_TYPE_BOOL == colType) { resType = TSDB_DATA_TYPE_BIGINT; } else { resType = TSDB_DATA_TYPE_DOUBLE; @@ -1841,7 +1841,7 @@ static int32_t translateToIso8601(SFunctionNode* pFunc, char* pErrBuf, int32_t l // param0 uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (!IS_INTEGER_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_INTEGER_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -1894,7 +1894,7 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_ uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; uint8_t para2Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type; - if ((!IS_STR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) && TSDB_DATA_TYPE_TIMESTAMP != para1Type) || + if ((!IS_STR_DATA_TYPE(para1Type) && !IS_INTEGER_TYPE(para1Type) && !IS_TIMESTAMP_TYPE(para1Type)) || !IS_INTEGER_TYPE(para2Type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -1927,7 +1927,7 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le for (int32_t i = 0; i < 2; ++i) { uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, i))->resType.type; - if (!IS_STR_DATA_TYPE(paraType) && !IS_INTEGER_TYPE(paraType) && TSDB_DATA_TYPE_TIMESTAMP != paraType) { + if (!IS_STR_DATA_TYPE(paraType) && !IS_INTEGER_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } } From 593fdce02efb189a20d6fe0e0d34932912751d1b Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Wed, 31 Aug 2022 19:28:12 +0800 Subject: [PATCH 3/4] fix test cases --- tests/system-test/2-query/max.py | 32 ++++++++++++++++--- tests/system-test/2-query/min.py | 54 +++++++++++++++++++++++--------- 2 files changed, 67 insertions(+), 19 deletions(-) diff --git a/tests/system-test/2-query/max.py b/tests/system-test/2-query/max.py index 34442a3725..3fc68395cc 100644 --- a/tests/system-test/2-query/max.py +++ b/tests/system-test/2-query/max.py @@ -29,9 +29,10 @@ class TDTestCase: % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) intData.append(i + 1) floatData.append(i + 0.1) - for i in ['ts','col11','col12','col13']: + + for i in ['col11','col12','col13']: for j in ['db.stb','stb','db.stb_1','stb_1']: - tdSql.error(f'select max({i} from {j} )') + tdSql.error(f'select max({i}) from {j}') for i in range(1,11): for j in ['db.stb','stb','db.stb_1','stb_1']: @@ -40,6 +41,20 @@ class TDTestCase: tdSql.checkData(0, 0, np.max(intData)) elif i>=9: tdSql.checkData(0, 0, np.max(floatData)) + + tdSql.query("select max(now()) from stb_1") + tdSql.checkRows(1) + + tdSql.query("select last(ts) from stb_1") + lastTs = tdSql.getData(0, 0) + tdSql.query("select max(ts) from stb_1") + tdSql.checkData(0, 0, lastTs) + + tdSql.query("select last(ts) from stb") + lastTs = tdSql.getData(0, 0) + tdSql.query("select max(ts) from stb") + tdSql.checkData(0, 0, lastTs) + tdSql.query("select max(col1) from stb_1 where col2<=5") tdSql.checkData(0,0,5) tdSql.query("select max(col1) from stb where col2<=5") @@ -57,9 +72,9 @@ class TDTestCase: % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) intData.append(i + 1) floatData.append(i + 0.1) - for i in ['ts','col11','col12','col13']: + for i in ['col11','col12','col13']: for j in ['db.ntb','ntb']: - tdSql.error(f'select max({i} from {j} )') + tdSql.error(f'select max({i}) from {j}') for i in range(1,11): for j in ['db.ntb','ntb']: tdSql.query(f"select max(col{i}) from {j}") @@ -67,6 +82,15 @@ class TDTestCase: tdSql.checkData(0, 0, np.max(intData)) elif i>=9: tdSql.checkData(0, 0, np.max(floatData)) + + tdSql.query("select max(now()) from ntb") + tdSql.checkRows(1) + + tdSql.query("select last(ts) from ntb") + lastTs = tdSql.getData(0, 0) + tdSql.query("select max(ts) from ntb") + tdSql.checkData(0, 0, lastTs) + tdSql.query("select max(col1) from ntb where col2<=5") tdSql.checkData(0,0,5) tdSql.execute('drop database db') diff --git a/tests/system-test/2-query/min.py b/tests/system-test/2-query/min.py index c27e9926ff..4230b302cb 100644 --- a/tests/system-test/2-query/min.py +++ b/tests/system-test/2-query/min.py @@ -36,17 +36,12 @@ class TDTestCase: floatData.append(i + 0.1) # max verifacation - tdSql.error("select min(ts) from stb_1") - tdSql.error("select min(ts) from db.stb_1") tdSql.error("select min(col7) from stb_1") tdSql.error("select min(col7) from db.stb_1") tdSql.error("select min(col8) from stb_1") tdSql.error("select min(col8) from db.stb_1") tdSql.error("select min(col9) from stb_1") tdSql.error("select min(col9) from db.stb_1") - # tdSql.error("select min(a) from stb_1") - # tdSql.error("select min(1) from stb_1") - tdSql.error("select min(now()) from stb_1") tdSql.error("select min(count(c1),count(c2)) from stb_1") tdSql.query("select min(col1) from stb_1") @@ -92,18 +87,26 @@ class TDTestCase: tdSql.query("select min(col1) from stb_1 where col2>=5") tdSql.checkData(0,0,5) + tdSql.query("select min(now()) from stb_1") + tdSql.checkRows(1) + + tdSql.query("select first(ts) from stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query("select min(ts) from stb_1") + tdSql.checkData(0, 0, firstTs) + + tdSql.query("select first(ts) from db.stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query("select min(ts) from db.stb_1") + tdSql.checkData(0, 0, firstTs) + - tdSql.error("select min(ts) from stb_1") - tdSql.error("select min(ts) from db.stb_1") tdSql.error("select min(col7) from stb_1") tdSql.error("select min(col7) from db.stb_1") tdSql.error("select min(col8) from stb_1") tdSql.error("select min(col8) from db.stb_1") tdSql.error("select min(col9) from stb_1") tdSql.error("select min(col9) from db.stb_1") - # tdSql.error("select min(a) from stb_1") - # tdSql.error("select min(1) from stb_1") - tdSql.error("select min(now()) from stb_1") tdSql.error("select min(count(c1),count(c2)) from stb_1") tdSql.query("select min(col1) from stb") @@ -149,18 +152,26 @@ class TDTestCase: tdSql.query("select min(col1) from stb where col2>=5") tdSql.checkData(0,0,5) + tdSql.query("select min(now()) from stb_1") + tdSql.checkRows(1) + + tdSql.query("select first(ts) from stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query("select min(ts) from stb_1") + tdSql.checkData(0, 0, firstTs) + + tdSql.query("select first(ts) from db.stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query("select min(ts) from db.stb_1") + tdSql.checkData(0, 0, firstTs) + - tdSql.error("select min(ts) from ntb") - tdSql.error("select min(ts) from db.ntb") tdSql.error("select min(col7) from ntb") tdSql.error("select min(col7) from db.ntb") tdSql.error("select min(col8) from ntb") tdSql.error("select min(col8) from db.ntb") tdSql.error("select min(col9) from ntb") tdSql.error("select min(col9) from db.ntb") - # tdSql.error("select min(a) from stb_1") - # tdSql.error("select min(1) from stb_1") - tdSql.error("select min(now()) from ntb") tdSql.error("select min(count(c1),count(c2)) from ntb") tdSql.query("select min(col1) from ntb") @@ -206,6 +217,19 @@ class TDTestCase: tdSql.query("select min(col1) from ntb where col2>=5") tdSql.checkData(0,0,5) + tdSql.query("select min(now()) from stb_1") + tdSql.checkRows(1) + + tdSql.query("select first(ts) from stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query("select min(ts) from stb_1") + tdSql.checkData(0, 0, firstTs) + + tdSql.query("select first(ts) from db.stb_1") + firstTs = tdSql.getData(0, 0) + tdSql.query("select min(ts) from db.stb_1") + tdSql.checkData(0, 0, firstTs) + def stop(self): tdSql.close() From 3d4807fbe98bba33a8725b73de0d9d32eb7692c6 Mon Sep 17 00:00:00 2001 From: Ganlin Zhao Date: Wed, 31 Aug 2022 19:28:12 +0800 Subject: [PATCH 4/4] fix test cases --- tests/script/tsim/stable/alter_comment.sim | 2 +- tests/script/tsim/stable/alter_count.sim | 8 +-- tests/script/tsim/stable/alter_import.sim | 4 +- tests/script/tsim/stable/alter_insert1.sim | 4 +- tests/script/tsim/stable/alter_insert2.sim | 4 +- tests/script/tsim/stable/alter_metrics.sim | 6 +- tests/script/tsim/stable/column_add.sim | 6 +- tests/script/tsim/stable/column_modify.sim | 6 +- tests/script/tsim/stable/disk.sim | 2 +- tests/script/tsim/stable/refcount.sim | 2 +- tests/script/tsim/stable/tag_add.sim | 6 +- tests/script/tsim/stable/tag_drop.sim | 12 ++-- tests/script/tsim/stable/tag_filter.sim | 66 +++++++++++----------- tests/script/tsim/stable/tag_modify.sim | 6 +- tests/script/tsim/stable/tag_rename.sim | 6 +- 15 files changed, 70 insertions(+), 70 deletions(-) diff --git a/tests/script/tsim/stable/alter_comment.sim b/tests/script/tsim/stable/alter_comment.sim index beb049985c..7c2d6edfcb 100644 --- a/tests/script/tsim/stable/alter_comment.sim +++ b/tests/script/tsim/stable/alter_comment.sim @@ -95,7 +95,7 @@ sql_error alter table db.stb add tag t1 int sql_error alter table db.stb add tag t2 int sql_error alter table db.stb add tag t3 int sql alter table db.stb add tag t4 bigint -sql alter table db.stb add tag c1 int +sql alter table db.stb add tag c1 int sql alter table db.stb add tag t5 binary(12) sql select * from information_schema.ins_stables where db_name = 'db' diff --git a/tests/script/tsim/stable/alter_count.sim b/tests/script/tsim/stable/alter_count.sim index 83ea4b14fa..4a2aeca029 100644 --- a/tests/script/tsim/stable/alter_count.sim +++ b/tests/script/tsim/stable/alter_count.sim @@ -5,8 +5,8 @@ print ========= start dnode1 as master system sh/exec.sh -n dnode1 -s start sql connect -print ======== step1 -sql create database d1 replica 1 duration 7 keep 50 +print ======== step1 +sql create database d1 replica 1 duration 7 keep 50 sql use d1 sql create table tb (ts timestamp, a int) sql insert into tb values(now-28d, -28) @@ -83,7 +83,7 @@ if $data00 != 3 then endi print ======== step8 -# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10) ) +# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10) ) sql alter table tb add column h binary(10) sql insert into tb values(now-7d, -7, 18, 0, 0, 0, 0, 0, '0') sql insert into tb values(now-6d, -6, 19, 1, 1, 1, 1, 1, '1') @@ -260,4 +260,4 @@ if $data00 != 31 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/alter_import.sim b/tests/script/tsim/stable/alter_import.sim index b968eb6a12..7431ea698a 100644 --- a/tests/script/tsim/stable/alter_import.sim +++ b/tests/script/tsim/stable/alter_import.sim @@ -5,7 +5,7 @@ print ========= start dnode1 as master system sh/exec.sh -n dnode1 -s start sql connect -print ======== step1 +print ======== step1 sql create database d1 replica 1 duration 7 keep 50 sql use d1 sql create table tb (ts timestamp, a int) @@ -42,4 +42,4 @@ if $data00 != 6 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/alter_insert1.sim b/tests/script/tsim/stable/alter_insert1.sim index bcea0b48c4..0e5617e92d 100644 --- a/tests/script/tsim/stable/alter_insert1.sim +++ b/tests/script/tsim/stable/alter_insert1.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -print ======== step1 +print ======== step1 sql create database d3 sql use d3 sql create table tb (ts timestamp, a int) @@ -1137,4 +1137,4 @@ if $data79 != null then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/alter_insert2.sim b/tests/script/tsim/stable/alter_insert2.sim index faae24d32a..a6046f3dda 100644 --- a/tests/script/tsim/stable/alter_insert2.sim +++ b/tests/script/tsim/stable/alter_insert2.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -print ======== step1 +print ======== step1 sql create database d4 sql use d4 sql create table tb (ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10)) @@ -662,4 +662,4 @@ if $data62 != null then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/alter_metrics.sim b/tests/script/tsim/stable/alter_metrics.sim index e32250de13..203f41e18b 100644 --- a/tests/script/tsim/stable/alter_metrics.sim +++ b/tests/script/tsim/stable/alter_metrics.sim @@ -3,7 +3,7 @@ system sh/deploy.sh -n dnode1 -i 1 system sh/exec.sh -n dnode1 -s start sql connect -print ======== step1 +print ======== step1 sql create database d2 sql use d2 sql create table mt (ts timestamp, a int) TAGS (t int) @@ -757,8 +757,8 @@ endi print ======= over sql drop database d2 sql select * from information_schema.ins_databases -if $rows != 2 then +if $rows != 2 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/column_add.sim b/tests/script/tsim/stable/column_add.sim index c0f3b4f490..05189f6c7d 100644 --- a/tests/script/tsim/stable/column_add.sim +++ b/tests/script/tsim/stable/column_add.sim @@ -116,7 +116,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != NULL then return -1 endi @@ -153,7 +153,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != NULL then return -1 endi @@ -299,4 +299,4 @@ if $rows != 10 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/column_modify.sim b/tests/script/tsim/stable/column_modify.sim index e2752ccf95..43284ba829 100644 --- a/tests/script/tsim/stable/column_modify.sim +++ b/tests/script/tsim/stable/column_modify.sim @@ -31,7 +31,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -92,7 +92,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -106,4 +106,4 @@ if $data[1][3] != 101 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/disk.sim b/tests/script/tsim/stable/disk.sim index e0e51b2625..8edd0a845e 100644 --- a/tests/script/tsim/stable/disk.sim +++ b/tests/script/tsim/stable/disk.sim @@ -188,4 +188,4 @@ if $rows != 2 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/refcount.sim b/tests/script/tsim/stable/refcount.sim index a83c0ca53f..35d8767efd 100644 --- a/tests/script/tsim/stable/refcount.sim +++ b/tests/script/tsim/stable/refcount.sim @@ -123,4 +123,4 @@ if $rows != 2 then endi print =============== step6 -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/tag_add.sim b/tests/script/tsim/stable/tag_add.sim index 7ee9aee974..4f5f0e7452 100644 --- a/tests/script/tsim/stable/tag_add.sim +++ b/tests/script/tsim/stable/tag_add.sim @@ -139,7 +139,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -170,7 +170,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -190,4 +190,4 @@ if $rows != 7 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/tag_drop.sim b/tests/script/tsim/stable/tag_drop.sim index 7902358817..b457bf195b 100644 --- a/tests/script/tsim/stable/tag_drop.sim +++ b/tests/script/tsim/stable/tag_drop.sim @@ -165,7 +165,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -196,7 +196,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 201 then return -1 endi @@ -229,7 +229,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 201 then return -1 endi @@ -261,7 +261,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 301 then return -1 endi @@ -323,7 +323,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 2 then return -1 -endi +endi if $data[0][3] != 302 then return -1 endi @@ -334,4 +334,4 @@ if $data[0][5] != 304 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/tag_filter.sim b/tests/script/tsim/stable/tag_filter.sim index f44142fbbf..de2a87d6c4 100644 --- a/tests/script/tsim/stable/tag_filter.sim +++ b/tests/script/tsim/stable/tag_filter.sim @@ -27,47 +27,47 @@ sql create table db.ctb6 using db.stb tags(6, "102") sql insert into db.ctb6 values(now, 6, "2") sql select * from db.stb where t1 = 1 -if $rows != 1 then +if $rows != 1 then return -1 endi -sql select * from db.stb where t1 < 1 -if $rows != 0 then +sql select * from db.stb where t1 < 1 +if $rows != 0 then return -=1 endi -sql select * from db.stb where t1 < 2 -if $rows != 1 then +sql select * from db.stb where t1 < 2 +if $rows != 1 then return -1 endi -sql select * from db.stb where t1 <= 2 -if $rows != 2 then +sql select * from db.stb where t1 <= 2 +if $rows != 2 then return -1 endi -sql select * from db.stb where t1 >= 1 -if $rows != 6 then +sql select * from db.stb where t1 >= 1 +if $rows != 6 then return -1 endi -sql select * from db.stb where t1 > 1 -if $rows != 5 then +sql select * from db.stb where t1 > 1 +if $rows != 5 then return -1 endi -sql select * from db.stb where t1 between 1 and 1 -if $rows != 1 then +sql select * from db.stb where t1 between 1 and 1 +if $rows != 1 then return -1 endi -sql select * from db.stb where t1 between 1 and 6 -if $rows != 6 then +sql select * from db.stb where t1 between 1 and 6 +if $rows != 6 then return -1 endi -sql select * from db.stb where t1 between 1 and 7 -if $rows != 6 then +sql select * from db.stb where t1 between 1 and 7 +if $rows != 6 then return -1 endi @@ -88,25 +88,25 @@ sql insert into db.ctbBin2 values(now, 3, "2") sql create table db.ctbBin3 using db.stbBin tags("d") sql insert into db.ctbBin3 values(now, 4, "2") -sql select * from db.stbBin where t1 = "a" -if $rows != 1 then +sql select * from db.stbBin where t1 = "a" +if $rows != 1 then return -1 endi -sql select * from db.stbBin where t1 < "a" -if $rows != 0 then +sql select * from db.stbBin where t1 < "a" +if $rows != 0 then return -=1 endi -sql select * from db.stbBin where t1 < "b" -if $rows != 1 then +sql select * from db.stbBin where t1 < "b" +if $rows != 1 then return -1 endi -sql select * from db.stbBin where t1 between "a" and "e" -if $rows != 4 then +sql select * from db.stbBin where t1 between "a" and "e" +if $rows != 4 then return -1 endi @@ -127,25 +127,25 @@ sql insert into db.ctbNc2 values(now, 3, "2") sql create table db.ctbNc3 using db.stbNc tags("d") sql insert into db.ctbNc3 values(now, 4, "2") -sql select * from db.stbNc where t1 = "a" -if $rows != 1 then +sql select * from db.stbNc where t1 = "a" +if $rows != 1 then return -1 endi -sql select * from db.stbNc where t1 < "a" -if $rows != 0 then +sql select * from db.stbNc where t1 < "a" +if $rows != 0 then return -=1 endi -sql select * from db.stbNc where t1 < "b" -if $rows != 1 then +sql select * from db.stbNc where t1 < "b" +if $rows != 1 then return -1 endi -sql select * from db.stbNc where t1 between "a" and "e" -if $rows != 4 then +sql select * from db.stbNc where t1 between "a" and "e" +if $rows != 4 then return -1 endi system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/tag_modify.sim b/tests/script/tsim/stable/tag_modify.sim index 909ed79359..53e7227d1b 100644 --- a/tests/script/tsim/stable/tag_modify.sim +++ b/tests/script/tsim/stable/tag_modify.sim @@ -28,7 +28,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -55,7 +55,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -120,4 +120,4 @@ if $data[4][2] != 5 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stable/tag_rename.sim b/tests/script/tsim/stable/tag_rename.sim index 5bdfa24990..c85ed183de 100644 --- a/tests/script/tsim/stable/tag_rename.sim +++ b/tests/script/tsim/stable/tag_rename.sim @@ -28,7 +28,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -52,7 +52,7 @@ if $data[0][1] != 1 then endi if $data[0][2] != 1234 then return -1 -endi +endi if $data[0][3] != 101 then return -1 endi @@ -117,4 +117,4 @@ if $data[4][2] != 4 then return -1 endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT