未验证 提交 41eb895d 编写于 作者: D dapan1121 提交者: GitHub

Merge pull request #7342 from taosdata/feature/TD-2573

[TD-2573]<feature>: ceil, floor and round functions are supported
......@@ -2551,6 +2551,9 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
case TSDB_FUNC_MAX:
case TSDB_FUNC_DIFF:
case TSDB_FUNC_DERIVATIVE:
case TSDB_FUNC_CEIL:
case TSDB_FUNC_FLOOR:
case TSDB_FUNC_ROUND:
case TSDB_FUNC_STDDEV:
case TSDB_FUNC_LEASTSQR: {
// 1. valid the number of parameters
......@@ -2741,6 +2744,10 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex);
if (pParamElem->pNode->columnName.z == NULL) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
}
// functions can not be applied to tags
if ((index.columnIndex >= tscGetNumOfColumns(pTableMetaInfo->pTableMeta)) || (index.columnIndex < 0)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg6);
......@@ -3474,6 +3481,7 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool
int32_t scalarUdf = 0;
int32_t prjNum = 0;
int32_t aggNum = 0;
int32_t scalNum = 0;
size_t numOfExpr = tscNumOfExprs(pQueryInfo);
assert(numOfExpr > 0);
......@@ -3505,6 +3513,10 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool
++prjNum;
}
if (functionId == TSDB_FUNC_CEIL || functionId == TSDB_FUNC_FLOOR || functionId == TSDB_FUNC_ROUND) {
++scalNum;
}
if (functionId == TSDB_FUNC_PRJ && (pExpr1->base.colInfo.colId == PRIMARYKEY_TIMESTAMP_COL_INDEX || TSDB_COL_IS_UD_COL(pExpr1->base.colInfo.flag))) {
continue;
}
......@@ -3526,15 +3538,19 @@ static bool functionCompatibleCheck(SQueryInfo* pQueryInfo, bool joinQuery, bool
}
}
aggNum = (int32_t)size - prjNum - aggUdf - scalarUdf;
aggNum = (int32_t)size - prjNum - scalNum - aggUdf - scalarUdf;
assert(aggNum >= 0);
if (aggUdf > 0 && (prjNum > 0 || aggNum > 0 || scalarUdf > 0)) {
if (aggUdf > 0 && (prjNum > 0 || aggNum > 0 || scalNum > 0 || scalarUdf > 0)) {
return false;
}
if (scalarUdf > 0 && (aggNum > 0 || scalNum > 0)) {
return false;
}
if (scalarUdf > 0 && aggNum > 0) {
if (aggNum > 0 && scalNum > 0) {
return false;
}
......@@ -6536,7 +6552,9 @@ int32_t validateFunctionsInIntervalOrGroupbyQuery(SSqlCmd* pCmd, SQueryInfo* pQu
}
int32_t f = pExpr->base.functionId;
if ((f == TSDB_FUNC_PRJ && pExpr->base.numOfParams == 0) || f == TSDB_FUNC_DIFF || f == TSDB_FUNC_ARITHM || f == TSDB_FUNC_DERIVATIVE) {
if ((f == TSDB_FUNC_PRJ && pExpr->base.numOfParams == 0) || f == TSDB_FUNC_DIFF || f == TSDB_FUNC_ARITHM || f == TSDB_FUNC_DERIVATIVE ||
f == TSDB_FUNC_CEIL || f == TSDB_FUNC_FLOOR || f == TSDB_FUNC_ROUND)
{
isProjectionFunction = true;
break;
}
......@@ -7138,6 +7156,7 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) {
const char* msg2 = "aggregation function should not be mixed up with projection";
bool tagTsColExists = false;
int16_t numOfScalar = 0;
int16_t numOfSelectivity = 0;
int16_t numOfAggregation = 0;
......@@ -7171,6 +7190,8 @@ static int32_t checkUpdateTagPrjFunctions(SQueryInfo* pQueryInfo, char* msg) {
if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) {
numOfSelectivity++;
} else if ((aAggs[functionId].status & TSDB_FUNCSTATE_SCALAR) != 0) {
numOfScalar++;
} else {
numOfAggregation++;
}
......
......@@ -269,7 +269,10 @@ bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex) {
functionId != TSDB_FUNC_DIFF &&
functionId != TSDB_FUNC_DERIVATIVE &&
functionId != TSDB_FUNC_TS_DUMMY &&
functionId != TSDB_FUNC_TID_TAG) {
functionId != TSDB_FUNC_TID_TAG &&
functionId != TSDB_FUNC_CEIL &&
functionId != TSDB_FUNC_FLOOR &&
functionId != TSDB_FUNC_ROUND) {
return false;
}
}
......@@ -1465,7 +1468,12 @@ void tscFreeSubobj(SSqlObj* pSql) {
tscDebug("0x%"PRIx64" start to free sub SqlObj, numOfSub:%d", pSql->self, pSql->subState.numOfSub);
for(int32_t i = 0; i < pSql->subState.numOfSub; ++i) {
tscDebug("0x%"PRIx64" free sub SqlObj:0x%"PRIx64", index:%d", pSql->self, pSql->pSubs[i]->self, i);
if (pSql->pSubs[i] != NULL) {
tscDebug("0x%"PRIx64" free sub SqlObj:0x%"PRIx64", index:%d", pSql->self, pSql->pSubs[i]->self, i);
} else {
/* just for python error test case */
tscDebug("0x%"PRIx64" free sub SqlObj:0x0, index:%d", pSql->self, i);
}
taos_free_result(pSql->pSubs[i]);
pSql->pSubs[i] = NULL;
}
......
......@@ -70,14 +70,14 @@ extern "C" {
#define TSDB_FUNC_DERIVATIVE 32
#define TSDB_FUNC_BLKINFO 33
#define TSDB_FUNC_HISTOGRAM 34
#define TSDB_FUNC_HLL 35
#define TSDB_FUNC_MODE 36
#define TSDB_FUNC_SAMPLE 37
#define TSDB_FUNC_CEIL 38
#define TSDB_FUNC_FLOOR 39
#define TSDB_FUNC_ROUND 40
#define TSDB_FUNC_CEIL 34
#define TSDB_FUNC_FLOOR 35
#define TSDB_FUNC_ROUND 36
#define TSDB_FUNC_HISTOGRAM 37
#define TSDB_FUNC_HLL 38
#define TSDB_FUNC_MODE 39
#define TSDB_FUNC_SAMPLE 40
#define TSDB_FUNC_MAVG 41
#define TSDB_FUNC_CSUM 42
......@@ -88,6 +88,7 @@ extern "C" {
#define TSDB_FUNCSTATE_OF 0x10u // outer forward
#define TSDB_FUNCSTATE_NEED_TS 0x20u // timestamp is required during query processing
#define TSDB_FUNCSTATE_SELECTIVITY 0x40u // selectivity functions, can exists along with tag columns
#define TSDB_FUNCSTATE_SCALAR 0x80u
#define TSDB_BASE_FUNC_SO TSDB_FUNCSTATE_SO | TSDB_FUNCSTATE_STREAM | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_OF
#define TSDB_BASE_FUNC_MO TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STREAM | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_OF
......
......@@ -179,7 +179,9 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
if (functionId == TSDB_FUNC_TS || functionId == TSDB_FUNC_TS_DUMMY || functionId == TSDB_FUNC_TAG_DUMMY ||
functionId == TSDB_FUNC_DIFF || functionId == TSDB_FUNC_PRJ || functionId == TSDB_FUNC_TAGPRJ ||
functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_INTERP) {
functionId == TSDB_FUNC_TAG || functionId == TSDB_FUNC_INTERP || functionId == TSDB_FUNC_CEIL ||
functionId == TSDB_FUNC_FLOOR || functionId == TSDB_FUNC_ROUND)
{
*type = (int16_t)dataType;
*bytes = (int16_t)dataBytes;
......@@ -405,7 +407,7 @@ int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionI
// TODO use hash table
int32_t isValidFunction(const char* name, int32_t len) {
for(int32_t i = 0; i <= TSDB_FUNC_BLKINFO; ++i) {
for(int32_t i = 0; i <= TSDB_FUNC_ROUND; ++i) {
int32_t nameLen = (int32_t) strlen(aAggs[i].name);
if (len != nameLen) {
continue;
......@@ -4256,6 +4258,231 @@ void blockinfo_func_finalizer(SQLFunctionCtx* pCtx) {
doFinalizer(pCtx);
}
#define CFR_SET_VAL(type, data, pCtx, func, i, step, notNullElems) \
do { \
type *pData = (type *) data; \
type *pOutput = (type *) pCtx->pOutput; \
\
for (; i < pCtx->size && i >= 0; i += step) { \
if (pCtx->hasNull && isNull((const char*) &pData[i], pCtx->inputType)) { \
continue; \
} \
\
*pOutput++ = (type) func((double) pData[i]); \
\
notNullElems++; \
} \
} while (0)
#define CFR_SET_VAL_DOUBLE(data, pCtx, func, i, step, notNullElems) \
do { \
double *pData = (double *) data; \
double *pOutput = (double *) pCtx->pOutput; \
\
for (; i < pCtx->size && i >= 0; i += step) { \
if (pCtx->hasNull && isNull((const char*) &pData[i], pCtx->inputType)) { \
continue; \
} \
\
SET_DOUBLE_VAL(pOutput, func(pData[i])); \
pOutput++; \
\
notNullElems++; \
} \
} while (0)
static void ceil_function(SQLFunctionCtx *pCtx) {
void *data = GET_INPUT_DATA_LIST(pCtx);
int32_t notNullElems = 0;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order);
int32_t i = (pCtx->order == TSDB_ORDER_ASC) ? 0 : pCtx->size - 1;
switch (pCtx->inputType) {
case TSDB_DATA_TYPE_INT: {
CFR_SET_VAL(int32_t, data, pCtx, ceil, i, step, notNullElems);
break;
};
case TSDB_DATA_TYPE_UINT: {
CFR_SET_VAL(uint32_t, data, pCtx, ceil, i, step, notNullElems);
break;
};
case TSDB_DATA_TYPE_BIGINT: {
CFR_SET_VAL(int64_t, data, pCtx, ceil, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_UBIGINT: {
CFR_SET_VAL(uint64_t, data, pCtx, ceil, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_DOUBLE: {
CFR_SET_VAL_DOUBLE(data, pCtx, ceil, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_FLOAT: {
CFR_SET_VAL(float, data, pCtx, ceil, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_SMALLINT: {
CFR_SET_VAL(int16_t, data, pCtx, ceil, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_USMALLINT: {
CFR_SET_VAL(uint16_t, data, pCtx, ceil, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_TINYINT: {
CFR_SET_VAL(int8_t, data, pCtx, ceil, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_UTINYINT: {
CFR_SET_VAL(uint8_t, data, pCtx, ceil, i, step, notNullElems);
break;
}
default:
qError("error input type");
}
if (notNullElems <= 0) {
/*
* current block may be null value
*/
assert(pCtx->hasNull);
} else {
GET_RES_INFO(pCtx)->numOfRes += notNullElems;
}
}
static void floor_function(SQLFunctionCtx *pCtx) {
void *data = GET_INPUT_DATA_LIST(pCtx);
int32_t notNullElems = 0;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order);
int32_t i = (pCtx->order == TSDB_ORDER_ASC) ? 0 : pCtx->size - 1;
switch (pCtx->inputType) {
case TSDB_DATA_TYPE_INT: {
CFR_SET_VAL(int32_t, data, pCtx, floor, i, step, notNullElems);
break;
};
case TSDB_DATA_TYPE_UINT: {
CFR_SET_VAL(uint32_t, data, pCtx, floor, i, step, notNullElems);
break;
};
case TSDB_DATA_TYPE_BIGINT: {
CFR_SET_VAL(int64_t, data, pCtx, floor, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_UBIGINT: {
CFR_SET_VAL(uint64_t, data, pCtx, floor, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_DOUBLE: {
CFR_SET_VAL_DOUBLE(data, pCtx, floor, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_FLOAT: {
CFR_SET_VAL(float, data, pCtx, floor, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_SMALLINT: {
CFR_SET_VAL(int16_t, data, pCtx, floor, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_USMALLINT: {
CFR_SET_VAL(uint16_t, data, pCtx, floor, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_TINYINT: {
CFR_SET_VAL(int8_t, data, pCtx, floor, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_UTINYINT: {
CFR_SET_VAL(uint8_t, data, pCtx, floor, i, step, notNullElems);
break;
}
default:
qError("error input type");
}
if (notNullElems <= 0) {
/*
* current block may be null value
*/
assert(pCtx->hasNull);
} else {
GET_RES_INFO(pCtx)->numOfRes += notNullElems;
}
}
static void round_function(SQLFunctionCtx *pCtx) {
void *data = GET_INPUT_DATA_LIST(pCtx);
int32_t notNullElems = 0;
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->order);
int32_t i = (pCtx->order == TSDB_ORDER_ASC) ? 0 : pCtx->size - 1;
switch (pCtx->inputType) {
case TSDB_DATA_TYPE_INT: {
CFR_SET_VAL(int32_t, data, pCtx, round, i, step, notNullElems);
break;
};
case TSDB_DATA_TYPE_UINT: {
CFR_SET_VAL(uint32_t, data, pCtx, round, i, step, notNullElems);
break;
};
case TSDB_DATA_TYPE_BIGINT: {
CFR_SET_VAL(int64_t, data, pCtx, round, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_UBIGINT: {
CFR_SET_VAL(uint64_t, data, pCtx, round, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_DOUBLE: {
CFR_SET_VAL_DOUBLE(data, pCtx, round, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_FLOAT: {
CFR_SET_VAL(float, data, pCtx, round, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_SMALLINT: {
CFR_SET_VAL(int16_t, data, pCtx, round, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_USMALLINT: {
CFR_SET_VAL(uint16_t, data, pCtx, round, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_TINYINT: {
CFR_SET_VAL(int8_t, data, pCtx, round, i, step, notNullElems);
break;
}
case TSDB_DATA_TYPE_UTINYINT: {
CFR_SET_VAL(uint8_t, data, pCtx, round, i, step, notNullElems);
break;
}
default:
qError("error input type");
}
if (notNullElems <= 0) {
/*
* current block may be null value
*/
assert(pCtx->hasNull);
} else {
GET_RES_INFO(pCtx)->numOfRes += notNullElems;
}
}
#undef CFR_SET_VAL
#undef CFR_SET_VAL_DOUBLE
/////////////////////////////////////////////////////////////////////////////////////////////
/*
* function compatible list.
......@@ -4274,8 +4501,8 @@ int32_t functionCompatList[] = {
4, -1, -1, 1, 1, 1, 1, 1, 1, -1,
// tag, colprj, tagprj, arithmetic, diff, first_dist, last_dist, stddev_dst, interp rate irate
1, 1, 1, 1, -1, 1, 1, 1, 5, 1, 1,
// tid_tag, derivative, blk_info
6, 8, 7,
// tid_tag, derivative, blk_info,ceil, floor, round
6, 8, 7, 1, 1, 1
};
SAggFunctionInfo aAggs[] = {{
......@@ -4678,7 +4905,7 @@ SAggFunctionInfo aAggs[] = {{
dataBlockRequired,
},
{
// 33
// 33
"_block_dist", // return table id and the corresponding tags for join match and subscribe
TSDB_FUNC_BLKINFO,
TSDB_FUNC_BLKINFO,
......@@ -4688,4 +4915,40 @@ SAggFunctionInfo aAggs[] = {{
blockinfo_func_finalizer,
block_func_merge,
dataBlockRequired,
},
{
// 34
"ceil",
TSDB_FUNC_CEIL,
TSDB_FUNC_CEIL,
TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SCALAR,
function_setup,
ceil_function,
doFinalizer,
noop1,
dataBlockRequired
},
{
// 35
"floor",
TSDB_FUNC_FLOOR,
TSDB_FUNC_FLOOR,
TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SCALAR,
function_setup,
floor_function,
doFinalizer,
noop1,
dataBlockRequired
},
{
// 36
"round",
TSDB_FUNC_ROUND,
TSDB_FUNC_ROUND,
TSDB_FUNCSTATE_MO | TSDB_FUNCSTATE_STABLE | TSDB_FUNCSTATE_NEED_TS | TSDB_FUNCSTATE_SCALAR,
function_setup,
round_function,
doFinalizer,
noop1,
dataBlockRequired
}};
......@@ -405,6 +405,25 @@ static bool isSelectivityWithTagsQuery(SQLFunctionCtx *pCtx, int32_t numOfOutput
return (numOfSelectivity > 0 && hasTags);
}
static bool isScalarWithTagsQuery(SQLFunctionCtx *pCtx, int32_t numOfOutput) {
bool hasTags = false;
int32_t numOfScalar = 0;
for (int32_t i = 0; i < numOfOutput; ++i) {
int32_t functId = pCtx[i].functionId;
if (functId == TSDB_FUNC_TAG_DUMMY || functId == TSDB_FUNC_TS_DUMMY) {
hasTags = true;
continue;
}
if ((aAggs[functId].status & TSDB_FUNCSTATE_SCALAR) != 0) {
numOfScalar++;
}
}
return (numOfScalar > 0 && hasTags);
}
static bool isProjQuery(SQueryAttr *pQueryAttr) {
for (int32_t i = 0; i < pQueryAttr->numOfOutput; ++i) {
int32_t functId = pQueryAttr->pExpr1[i].base.functionId;
......@@ -1939,7 +1958,7 @@ void setBlockStatisInfo(SQLFunctionCtx *pCtx, SSDataBlock* pSDataBlock, SColInde
// set the output buffer for the selectivity + tag query
static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) {
if (!isSelectivityWithTagsQuery(pCtx, numOfOutput)) {
if (!isSelectivityWithTagsQuery(pCtx, numOfOutput) && !isScalarWithTagsQuery(pCtx, numOfOutput)) {
return TSDB_CODE_SUCCESS;
}
......@@ -1958,7 +1977,7 @@ static int32_t setCtxTagColumnInfo(SQLFunctionCtx *pCtx, int32_t numOfOutput) {
if (functionId == TSDB_FUNC_TAG_DUMMY || functionId == TSDB_FUNC_TS_DUMMY) {
tagLen += pCtx[i].outputBytes;
pTagCtx[num++] = &pCtx[i];
} else if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0) {
} else if ((aAggs[functionId].status & TSDB_FUNCSTATE_SELECTIVITY) != 0 || (aAggs[functionId].status & TSDB_FUNCSTATE_SCALAR) != 0) {
p = &pCtx[i];
} else if (functionId == TSDB_FUNC_TS || functionId == TSDB_FUNC_TAG) {
// tag function may be the group by tag column
......
......@@ -645,6 +645,12 @@ SArray* createExecOperatorPlan(SQueryAttr* pQueryAttr) {
} else {
op = OP_Project;
taosArrayPush(plan, &op);
if (pQueryAttr->pExpr2 != NULL) {
op = OP_Project;
taosArrayPush(plan, &op);
}
if (pQueryAttr->distinct) {
op = OP_Distinct;
taosArrayPush(plan, &op);
......
......@@ -359,6 +359,9 @@ python3 ./test.py -f functions/queryTestCases.py
python3 ./test.py -f functions/function_stateWindow.py
python3 ./test.py -f functions/function_derivative.py
python3 ./test.py -f functions/function_irate.py
python3 ./test.py -f functions/function_ceil.py
python3 ./test.py -f functions/function_floor.py
python3 ./test.py -f functions/function_round.py
python3 ./test.py -f insert/unsignedInt.py
python3 ./test.py -f insert/unsignedBigint.py
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
$dbPrefix = m_di_db
$tbPrefix = m_di_tb
$mtPrefix = m_di_mt
$tbNum = 2
$rowNum = 5000
print =============== step1
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
sql drop database $db -x step1
step1:
sql create database $db
sql use $db
sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int)
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using $mt tags( $i )
$x = 0
$y = 0
$v0 = 5000.0
$v1 = -5000.1
$v2 = 5000.2
$v3 = -5000.3
$v4 = 5000.4
$v5 = -5000.5
$v6 = 5000.6
$v7 = -5000.7
$v8 = 5000.8
$v9 = -5000.9
while $x < $rowNum
$cc = $x * 60000
$ms = 1601481600000 + $cc
$val = $v0
if $y == 0 then
$val = $v0
endi
if $y == 1 then
$val = $v1
endi
if $y == 2 then
$val = $v2
endi
if $y == 3 then
$val = $v3
endi
if $y == 4 then
$val = $v4
endi
if $y == 5 then
$val = $v5
endi
if $y == 6 then
$val = $v6
endi
if $y == 7 then
$val = $v7
endi
if $y == 8 then
$val = $v8
endi
if $y == 9 then
$val = $v9
endi
$tinyint = $x / 128
sql insert into $tb values ($ms , $x , $val , $x , $x , $tinyint , $x , $x , $x , $x )
$x = $x + 1
$y = $y + 1
if $y == 10 then
$y = 0
endi
endw
$i = $i + 1
endw
sleep 100
print =============== step2
$i = 1
$tb = $tbPrefix . $i
sql select ceil(c2) from $tb
print ===> $data00
if $data00 != 5000.00000 then
return -1
endi
sql select ceil(c2) from $tb
print ===> $data10
if $data10 != -5000.00000 then
return -1
endi
sql select ceil(c2) from $tb
print ===> $data20
if $data20 != 5001.00000 then
return -1
endi
sql select ceil(c2) from $tb
print ===> $data30
if $data30 != -5000.00000 then
return -1
endi
sql select ceil(c2) from $tb
print ===> $data40
if $data40 != 5001.00000 then
return -1
endi
sql select ceil(c2) from $tb
print ===> $data50
if $data50 != -5000.00000 then
return -1
endi
sql select ceil(c2) from $tb
print ===> $data60
if $data60 != 5001.00000 then
return -1
endi
sql select ceil(c2) from $tb
print ===> $data70
if $data70 != -5000.00000 then
return -1
endi
sql select ceil(c2) from $tb
print ===> $data80
if $data80 != 5001.00000 then
return -1
endi
sql select ceil(c2) from $tb
print ===> $data90
if $data90 != -5000.00000 then
return -1
endi
sql select ceil(c5) from $tb
print ===> $data10
if $data10 != 0 then
return -1
endi
sql select ts, ceil(c2) from $tb
sql select c2, ceil(c2) from $tb
sql select c2, c3, ceil(c2) from $tb
sql select ts, c2, c3, ceil(c2) from $tb
sql select ceil(c2), ceil(c6) from $tb
sql select ts, ceil(c2), ceil(c6) from $tb
sql select c2, ceil(c2), ceil(c6) from $tb
sql select c2, c3, ceil(c2), ceil(c6) from $tb
sql select ts, c2, c3, ceil(c2), ceil(c6) from $tb
sql select ceil(c2), floor(c2), round(c2) from $tb
sql select ts, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, ceil(c2) from $mt
sql select c2, ceil(c2) from $mt
sql select c2, c3, ceil(c2) from $mt
sql select ts, c2, c3, ceil(c2) from $mt
sql select ceil(c2), ceil(c6) from $mt
sql select ts, ceil(c2), ceil(c6) from $mt
sql select c2, ceil(c2), ceil(c6) from $mt
sql select c2, c3, ceil(c2), ceil(c6) from $mt
sql select ts, c2, c3, ceil(c2), ceil(c6) from $mt
sql select ceil(c2), ceil(c2), round(c2) from $mt
sql select ts, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql_error select ceil(c7) from $tb
sql_error select ceil(c8) from $tb
sql_error select ceil(c9) from $tb
sql_error select ceil(ts) from $tb
sql_error select ceil(c2+2) from $tb
sql_error select ceil(c2) from $tb where ts > 0 and ts < now + 100m interval(10m)
sql_error select ceil(ceil(c2)) from $tb
sql_error select ceil(c2) from m_di_tb1 where c2 like '2%'
print =============== step3
sql select ceil(c2) from $tb where c2 <= 5001.00000
print ===> $data00
if $data00 != 5000.00000 then
return -1
endi
sql select ceil(c2) from $tb where c2 <= 5001.00000
print ===> $data10
if $data10 != -5000.00000 then
return -1
endi
sql select ceil(c2) from $tb where c2 <= 5001.00000
print ===> $data20
if $data20 != 5001.00000 then
return -1
endi
sql select ceil(c2) from $tb where c2 <= 5001.00000
print ===> $data70
if $data70 != -5000.00000 then
return -1
endi
sql select ceil(c2) from $tb where c2 <= 5001.00000
print ===> $data80
if $data80 != 5001.00000 then
return -1
endi
sql select ceil(c2) from $tb where c2 <= 5001.00000
print ===> $data90
if $data90 != -5000.00000 then
return -1
endi
print =============== step4
sql select ceil(c2) from $tb where c2 >= -5001.00000
print ===> $data00
if $data00 != 5000.00000 then
return -1
endi
sql select ceil(c2) from $tb where c2 >= -5001.00000
print ===> $data10
if $data10 != -5000.00000 then
return -1
endi
sql select ceil(c2) from $tb where c2 >= -5001.00000
print ===> $data20
if $data20 != 5001.00000 then
return -1
endi
sql select ceil(c2) from $tb where c2 >= -5001.00000
print ===> $data70
if $data70 != -5000.00000 then
return -1
endi
sql select ceil(c2) from $tb where c2 >= -5001.00000
print ===> $data80
if $data80 != 5001.00000 then
return -1
endi
sql select ceil(c2) from $tb where c2 >= -5001.00000
print ===> $data90
if $data90 != -5000.00000 then
return -1
endi
print =============== step5
sql select ceil(c1) as b from $tb interval(1m) -x step5
return -1
step5:
print =============== step6
sql select ceil(c1) as b from $tb where ts < now + 4m interval(1m) -x step6
return -1
step6:
print =============== clear
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
$dbPrefix = m_di_db
$tbPrefix = m_di_tb
$mtPrefix = m_di_mt
$tbNum = 2
$rowNum = 10000
print =============== step1
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
sql drop database $db -x step1
step1:
sql create database $db
sql use $db
sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int)
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using $mt tags( $i )
$x = 0
$y = 0
$v0 = 5000.0
$v1 = -5000.1
$v2 = 5000.2
$v3 = -5000.3
$v4 = 5000.4
$v5 = -5000.5
$v6 = 5000.6
$v7 = -5000.7
$v8 = 5000.8
$v9 = -5000.9
while $x < $rowNum
$cc = $x * 60000
$ms = 1601481600000 + $cc
$val = $v0
if $y == 0 then
$val = $v0
endi
if $y == 1 then
$val = $v1
endi
if $y == 2 then
$val = $v2
endi
if $y == 3 then
$val = $v3
endi
if $y == 4 then
$val = $v4
endi
if $y == 5 then
$val = $v5
endi
if $y == 6 then
$val = $v6
endi
if $y == 7 then
$val = $v7
endi
if $y == 8 then
$val = $v8
endi
if $y == 9 then
$val = $v9
endi
$tinyint = $x / 128
sql insert into $tb values ($ms , $x , $val , $x , $x , $tinyint , $x , $x , $x , $x )
$x = $x + 1
$y = $y + 1
if $y == 10 then
$y = 0
endi
endw
$i = $i + 1
endw
sleep 100
print =============== step2
$i = 1
$tb = $tbPrefix . $i
sql select floor(c2) from $tb
print ===> $data00
if $data00 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb
print ===> $data10
if $data10 != -5001.00000 then
return -1
endi
sql select floor(c2) from $tb
print ===> $data20
if $data20 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb
print ===> $data30
if $data30 != -5001.00000 then
return -1
endi
sql select floor(c2) from $tb
print ===> $data40
if $data40 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb
print ===> $data50
if $data50 != -5001.00000 then
return -1
endi
sql select floor(c2) from $tb
print ===> $data60
if $data60 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb
print ===> $data70
if $data70 != -5001.00000 then
return -1
endi
sql select floor(c2) from $tb
print ===> $data80
if $data80 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb
print ===> $data90
if $data90 != -5001.00000 then
return -1
endi
sql select floor(c5) from $tb
print ===> $data10
if $data10 != 0 then
return -1
endi
sql select ts, floor(c2) from $tb
sql select c2, floor(c2) from $tb
sql select c2, c3, floor(c2) from $tb
sql select ts, c2, c3, floor(c2) from $tb
sql select floor(c2), floor(c6) from $tb
sql select ts, floor(c2), floor(c6) from $tb
sql select c2, floor(c2), floor(c6) from $tb
sql select c2, c3, floor(c2), floor(c6) from $tb
sql select ts, c2, c3, floor(c2), floor(c6) from $tb
sql select ceil(c2), floor(c2), round(c2) from $tb
sql select ts, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, floor(c2) from $mt
sql select c2, floor(c2) from $mt
sql select c2, c3, floor(c2) from $mt
sql select ts, c2, c3, floor(c2) from $mt
sql select floor(c2), floor(c6) from $mt
sql select ts, floor(c2), floor(c6) from $mt
sql select c2, floor(c2), floor(c6) from $mt
sql select c2, c3, floor(c2), floor(c6) from $mt
sql select ts, c2, c3, floor(c2), floor(c6) from $mt
sql select ceil(c2), floor(c2), round(c2) from $mt
sql select ts, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql_error select floor(c7) from $tb
sql_error select floor(c8) from $tb
sql_error select floor(c9) from $tb
sql_error select floor(ts) from $tb
sql_error select floor(c2+2) from $tb
sql_error select floor(c2) from $tb where ts > 0 and ts < now + 100m interval(10m)
sql_error select floor(floor(c2)) from $tb
sql_error select floor(c2) from m_di_tb1 where c2 like '2%'
print =============== step3
sql select floor(c2) from $tb where c2 <= 5001.00000
print ===> $data00
if $data00 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb where c2 <= 5001.00000
print ===> $data10
if $data10 != -5001.00000 then
return -1
endi
sql select floor(c2) from $tb where c2 <= 5001.00000
print ===> $data20
if $data20 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb where c2 <= 5001.00000
print ===> $data70
if $data70 != -5001.00000 then
return -1
endi
sql select floor(c2) from $tb where c2 <= 5001.00000
print ===> $data80
if $data80 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb where c2 <= 5001.00000
print ===> $data90
if $data90 != -5001.00000 then
return -1
endi
print =============== step4
sql select floor(c2) from $tb where c2 >= -5001.00000
print ===> $data00
if $data00 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb where c2 >= -5001.00000
print ===> $data10
if $data10 != -5001.00000 then
return -1
endi
sql select floor(c2) from $tb where c2 >= -5001.00000
print ===> $data20
if $data20 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb where c2 >= -5001.00000
print ===> $data70
if $data70 != -5001.00000 then
return -1
endi
sql select floor(c2) from $tb where c2 >= -5001.00000
print ===> $data80
if $data80 != 5000.00000 then
return -1
endi
sql select floor(c2) from $tb where c2 >= -5001.00000
print ===> $data90
if $data90 != -5001.00000 then
return -1
endi
print =============== step5
sql select floor(c1) as b from $tb interval(1m) -x step5
return -1
step5:
print =============== step6
sql select floor(c1) as b from $tb where ts < now + 4m interval(1m) -x step6
return -1
step6:
print =============== clear
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/cfg.sh -n dnode1 -c walLevel -v 1
system sh/exec.sh -n dnode1 -s start
sleep 2000
sql connect
$dbPrefix = m_di_db
$tbPrefix = m_di_tb
$mtPrefix = m_di_mt
$tbNum = 2
$rowNum = 10000
print =============== step1
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
sql drop database $db -x step1
step1:
sql create database $db
sql use $db
sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 nchar(5), c9 binary(10)) TAGS (tgcol int)
$i = 0
while $i < $tbNum
$tb = $tbPrefix . $i
sql create table $tb using $mt tags( $i )
$x = 0
$y = 0
$v0 = 5000.0
$v1 = -5000.1
$v2 = 5000.2
$v3 = -5000.3
$v4 = 5000.4
$v5 = -5000.5
$v6 = 5000.6
$v7 = -5000.7
$v8 = 5000.8
$v9 = -5000.9
while $x < $rowNum
$cc = $x * 60000
$ms = 1601481600000 + $cc
$val = $v0
if $y == 0 then
$val = $v0
endi
if $y == 1 then
$val = $v1
endi
if $y == 2 then
$val = $v2
endi
if $y == 3 then
$val = $v3
endi
if $y == 4 then
$val = $v4
endi
if $y == 5 then
$val = $v5
endi
if $y == 6 then
$val = $v6
endi
if $y == 7 then
$val = $v7
endi
if $y == 8 then
$val = $v8
endi
if $y == 9 then
$val = $v9
endi
$tinyint = $x / 128
sql insert into $tb values ($ms , $x , $val , $x , $x , $tinyint , $x , $x , $x , $x )
$x = $x + 1
$y = $y + 1
if $y == 10 then
$y = 0
endi
endw
$i = $i + 1
endw
sleep 100
print =============== step2
$i = 1
$tb = $tbPrefix . $i
sql select round(c2) from $tb
print ===> $data00
if $data00 != 5000.00000 then
return -1
endi
sql select round(c2) from $tb
print ===> $data10
if $data10 != -5000.00000 then
return -1
endi
sql select round(c2) from $tb
print ===> $data20
if $data20 != 5000.00000 then
return -1
endi
sql select round(c2) from $tb
print ===> $data30
if $data30 != -5000.00000 then
return -1
endi
sql select round(c2) from $tb
print ===> $data40
if $data40 != 5000.00000 then
return -1
endi
sql select round(c2) from $tb
print ===> $data50
if $data50 != -5001.00000 then
return -1
endi
sql select round(c2) from $tb
print ===> $data60
if $data60 != 5001.00000 then
return -1
endi
sql select round(c2) from $tb
print ===> $data70
if $data70 != -5001.00000 then
return -1
endi
sql select round(c2) from $tb
print ===> $data80
if $data80 != 5001.00000 then
return -1
endi
sql select round(c2) from $tb
print ===> $data90
if $data90 != -5001.00000 then
return -1
endi
sql select round(c5) from $tb
print ===> $data10
if $data10 != 0 then
return -1
endi
sql select ts, round(c2) from $tb
sql select c2, round(c2) from $tb
sql select c2, c3, round(c2) from $tb
sql select ts, c2, c3, round(c2) from $tb
sql select round(c2), round(c6) from $tb
sql select ts, round(c2), round(c6) from $tb
sql select c2, round(c2), round(c6) from $tb
sql select c2, c3, round(c2), round(c6) from $tb
sql select ts, c2, c3, round(c2), round(c6) from $tb
sql select ceil(c2), floor(c2), round(c2) from $tb
sql select ts, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, ceil(c2), floor(c2), round(c2) from $tb
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $tb
sql select ts, round(c2) from $mt
sql select c2, round(c2) from $mt
sql select c2, c3, round(c2) from $mt
sql select ts, c2, c3, round(c2) from $mt
sql select round(c2), round(c6) from $mt
sql select ts, round(c2), round(c6) from $mt
sql select c2, round(c2), round(c6) from $mt
sql select c2, c3, round(c2), round(c6) from $mt
sql select ts, c2, c3, round(c2), round(c6) from $mt
sql select ceil(c2), floor(c2), round(c2) from $mt
sql select ts, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, ceil(c2), floor(c2), round(c2) from $mt
sql select c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql select ts, c2, c3, ceil(c2), floor(c2), round(c2) from $mt
sql_error select round(c7) from $tb
sql_error select round(c8) from $tb
sql_error select round(c9) from $tb
sql_error select round(ts) from $tb
sql_error select round(c2+2) from $tb
sql_error select round(c2) from $tb where ts > 0 and ts < now + 100m interval(10m)
sql_error select round(round(c2)) from $tb
sql_error select round(c2) from m_di_tb1 where c2 like '2%'
print =============== step3
sql select round(c2) from $tb where c2 <= 5001.00000
print ===> $data00
if $data00 != 5000.00000 then
return -1
endi
sql select round(c2) from $tb where c2 <= 5001.00000
print ===> $data10
if $data10 != -5000.00000 then
return -1
endi
sql select round(c2) from $tb where c2 <= 5001.00000
print ===> $data20
if $data20 != 5000.00000 then
return -1
endi
sql select round(c2) from $tb where c2 <= 5001.00000
print ===> $data70
if $data70 != -5001.00000 then
return -1
endi
sql select round(c2) from $tb where c2 <= 5001.00000
print ===> $data80
if $data80 != 5001.00000 then
return -1
endi
sql select round(c2) from $tb where c2 <= 5001.00000
print ===> $data90
if $data90 != -5001.00000 then
return -1
endi
print =============== step4
sql select round(c2) from $tb where c2 >= -5001.00000
print ===> $data00
if $data00 != 5000.00000 then
return -1
endi
sql select round(c2) from $tb where c2 >= -5001.00000
print ===> $data10
if $data10 != -5000.00000 then
return -1
endi
sql select round(c2) from $tb where c2 >= -5001.00000
print ===> $data20
if $data20 != 5000.00000 then
return -1
endi
sql select round(c2) from $tb where c2 >= -5001.00000
print ===> $data70
if $data70 != -5001.00000 then
return -1
endi
sql select round(c2) from $tb where c2 >= -5001.00000
print ===> $data80
if $data80 != 5001.00000 then
return -1
endi
sql select round(c2) from $tb where c2 >= -5001.00000
print ===> $data90
if $data90 != -5001.00000 then
return -1
endi
print =============== step5
sql select round(c1) as b from $tb interval(1m) -x step5
return -1
step5:
print =============== step6
sql select round(c1) as b from $tb where ts < now + 4m interval(1m) -x step6
return -1
step6:
print =============== clear
system sh/exec.sh -n dnode1 -s stop -x SIGINT
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册