提交 a170da72 编写于 作者: H Haojun Liao

[td-1664]

上级 6b985a6e
......@@ -3385,10 +3385,26 @@ static int32_t validateSQLExpr(SSqlCmd* pCmd, tSQLExpr* pExpr, SQueryInfo* pQuer
tSQLExprItem item = {.pNode = pExpr, .aliasName = NULL};
// sql function in selection clause, append sql function info in pSqlCmd structure sequentially
// sql function list in selection clause.
// Append the sqlExpr into exprList of pQueryInfo structure sequentially
if (addExprAndResultField(pCmd, pQueryInfo, outputIndex, &item, false) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_TSC_INVALID_SQL;
}
// It is invalid in case of more than one sqlExpr, such as first(ts, k) - last(ts, k)
int32_t inc = (int32_t) tscSqlExprNumOfExprs(pQueryInfo) - outputIndex;
if (inc > 1) {
return TSDB_CODE_TSC_INVALID_SQL;
}
// Not supported data type in arithmetic expression
for(int32_t i = 0; i < inc; ++i) {
SSqlExpr* p1 = tscSqlExprGet(pQueryInfo, i + outputIndex);
int16_t t = p1->resType;
if (t == TSDB_DATA_TYPE_BINARY || t == TSDB_DATA_TYPE_NCHAR || t == TSDB_DATA_TYPE_BOOL || t == TSDB_DATA_TYPE_TIMESTAMP) {
return TSDB_CODE_TSC_INVALID_SQL;
}
}
}
return TSDB_CODE_SUCCESS;
......
......@@ -1247,7 +1247,10 @@ _bi_consumer_fn_t tGetBiConsumerFn(int32_t leftType, int32_t rightType, int32_t
case TSDB_BINARY_OP_REMAINDER:
return rem_function_arraylist[leftType][rightType];
default:
assert(0);
return NULL;
}
assert(0);
return NULL;
}
......@@ -109,4 +109,39 @@ if $data02 != 225000 then
return -1
endi
sql select first(speed) - last(speed), first(speed) as b, last(speed) as b, min(speed) - max(speed), spread(speed) from stb interval(1y)", NULL);
if $rows != 1 then
return -1
endi
if $data00 != @20-01-01 00:00:00.000@ then
return -1
endi
if $data01 != -20.000000000 then
return -1
endi
if $data02 != 100.000000000 then
return -1
endi
if $data03 != 120.000000000 then
return -1
endi
if $data04 != -20.000000000 then
return -1
endi
if $data05 != 20.000000000 then
return -1
endi
sql_error select first(speed, mileage) - last(speed, mileage) from stb interval(1y)
sql_error select first(ts) - last(ts) from stb interval(1y)
sql_error select top(speed, 2) - last(speed) from stb;
sql_error select stddev(speed) - last(speed) from stb;
sql_error select diff(speed) - last(speed) from stb;
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册