diff --git a/src/query/inc/qUtil.h b/src/query/inc/qUtil.h index 62bf245a2b66b13bcedc30fbd2502e1ad15dd8ec..bc23ffadd40e1b5285f442aa87b8de934d5a9ea4 100644 --- a/src/query/inc/qUtil.h +++ b/src/query/inc/qUtil.h @@ -81,6 +81,7 @@ int32_t getNumOfAllocatedResultRows(SResultRowPool* p); int32_t getNumOfUsedResultRows(SResultRowPool* p); uint64_t getResultInfoUId(SQueryRuntimeEnv* pRuntimeEnv); +bool isPointInterpoQuery(SQuery *pQuery); #endif // TDENGINE_QUERYUTIL_H diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 7d6068ff64ab2aff4c809f174c878db96b12ca27..fce25ae119bd842b59a5645bbe465c5de0c85f8a 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -1825,7 +1825,7 @@ static bool isFixedOutputQuery(SQueryRuntimeEnv* pRuntimeEnv) { } // todo refactor with isLastRowQuery -static bool isPointInterpoQuery(SQuery *pQuery) { +bool isPointInterpoQuery(SQuery *pQuery) { for (int32_t i = 0; i < pQuery->numOfOutput; ++i) { int32_t functionID = pQuery->pExpr1[i].base.functionId; if (functionID == TSDB_FUNC_INTERP) { diff --git a/src/query/src/qUtil.c b/src/query/src/qUtil.c index 4b8d7ea930aced09117d6fcc603fae8249af6b92..2b4cdef9b0b4a069ef4d3148b9ea67361ae88f7b 100644 --- a/src/query/src/qUtil.c +++ b/src/query/src/qUtil.c @@ -388,6 +388,12 @@ uint64_t getResultInfoUId(SQueryRuntimeEnv* pRuntimeEnv) { return 0; // for simple table query, the uid is always set to be 0; } + SQuery* pQuery = pRuntimeEnv->pQuery; + if ((pQuery->checkBuffer == 1 && pQuery->interval.interval == 0) || isPointInterpoQuery(pQuery) || + pRuntimeEnv->groupbyNormalCol) { + return 0; + } + STableId* id = TSDB_TABLEID(pRuntimeEnv->pQuery->current); return id->uid; } \ No newline at end of file diff --git a/tests/script/general/parser/col_arithmetic_query.sim b/tests/script/general/parser/col_arithmetic_query.sim index 95e0ed68d70879de995cb3289096acf175a20612..408b039144e1f3de16b2f58fc34b18b39ed9e5e6 100644 --- a/tests/script/general/parser/col_arithmetic_query.sim +++ b/tests/script/general/parser/col_arithmetic_query.sim @@ -323,9 +323,56 @@ sql select c2-c2, 911 from $tb #======================================= aggregation function arithmetic query cases ================ # asc/desc order [d.2] sql select first(c1) * ( 2 / 3 ) from $stb order by ts asc; -sql select (count(c1) * 2) % 7.9 from $stb order by ts desc; +if $rows != 1 then + return -1 +endi + +if $data00 != 0.000000000 then + return -1 +endi + +sql select first(c1) * (2/99) from $stb order by ts desc; +if $rows != 1 then + return -1 +endi + +if $data00 != 0.000000000 then + return -1 +endi + +sql select (count(c1) * 2) % 7.9, (count(c1) * 2), ( count(1)*2) from $stb order by ts desc; +if $rows != 1 then + return -1 +endi + +if $data00 != 1.800000000 then + return -1 +endi + +if $data01 != 100000 then + return -1 +endi + +if $data02 != 200000 then + return -1 +endi + +sql select spread( c1 )/44, spread(c1), 0.204545455 * 44 from $stb order by ts asc; +if $rows != 1 then + return -1 +endi + +if $data00 != 0.204545455 then + return -1 +endi -sql select spread(c1 )/44 from $stb order by ts asc; +if $data01 != 9.000000000 then + return -1 +endi + +if $data02 != 9.000000020 then + return -1 +endi # all possible function in the arithmetic expressioin sql select min(c1) * max(c2) /4, sum(c1) * percentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2) from $stb where ts < and ts >