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

Merge pull request #8553 from taosdata/szhou/hotfix/TD-10758

[TD-10758]<fix>:call tag_project to set tag values inside single table multi-ouput functions
......@@ -3178,7 +3178,14 @@ static void deriv_function(SQLFunctionCtx *pCtx) {
default:
qError("error input type");
}
if (notNullElems > 0) {
for (int t = 0; t < pCtx->tagInfo.numOfTagCols; ++t) {
SQLFunctionCtx* tagCtx = pCtx->tagInfo.pTagCtxList[t];
if (tagCtx->functionId == TSDB_FUNC_TAG_DUMMY) {
aAggs[TSDB_FUNC_TAGPRJ].xFunction(tagCtx);
}
}
}
GET_RES_INFO(pCtx)->numOfRes += notNullElems;
}
......@@ -3353,6 +3360,12 @@ static void diff_function(SQLFunctionCtx *pCtx) {
*/
assert(pCtx->hasNull);
} else {
for (int t = 0; t < pCtx->tagInfo.numOfTagCols; ++t) {
SQLFunctionCtx* tagCtx = pCtx->tagInfo.pTagCtxList[t];
if (tagCtx->functionId == TSDB_FUNC_TAG_DUMMY) {
aAggs[TSDB_FUNC_TAGPRJ].xFunction(tagCtx);
}
}
int32_t forwardStep = (isFirstBlock) ? notNullElems - 1 : notNullElems;
GET_RES_INFO(pCtx)->numOfRes += forwardStep;
......@@ -4727,8 +4740,6 @@ static void csum_function(SQLFunctionCtx *pCtx) {
TSKEY* pTimestamp = pCtx->ptsOutputBuf;
TSKEY* tsList = GET_TS_LIST(pCtx);
qDebug("%p csum_function() size:%d, hasNull:%d", pCtx, pCtx->size, pCtx->hasNull);
for (; i < pCtx->size && i >= 0; i += step) {
char* pData = GET_INPUT_DATA(pCtx, i);
if (pCtx->hasNull && isNull(pData, pCtx->inputType)) {
......@@ -4770,6 +4781,12 @@ static void csum_function(SQLFunctionCtx *pCtx) {
if (notNullElems == 0) {
assert(pCtx->hasNull);
} else {
for (int t = 0; t < pCtx->tagInfo.numOfTagCols; ++t) {
SQLFunctionCtx* tagCtx = pCtx->tagInfo.pTagCtxList[t];
if (tagCtx->functionId == TSDB_FUNC_TAG_DUMMY) {
aAggs[TSDB_FUNC_TAGPRJ].xFunction(tagCtx);
}
}
GET_RES_INFO(pCtx)->numOfRes += notNullElems;
GET_RES_INFO(pCtx)->hasResult = DATA_SET_FLAG;
}
......@@ -4843,6 +4860,12 @@ static void mavg_function(SQLFunctionCtx *pCtx) {
if (notNullElems <= 0) {
assert(pCtx->hasNull);
} else {
for (int t = 0; t < pCtx->tagInfo.numOfTagCols; ++t) {
SQLFunctionCtx* tagCtx = pCtx->tagInfo.pTagCtxList[t];
if (tagCtx->functionId == TSDB_FUNC_TAG_DUMMY) {
aAggs[TSDB_FUNC_TAGPRJ].xFunction(tagCtx);
}
}
GET_RES_INFO(pCtx)->numOfRes += notNullElems;
GET_RES_INFO(pCtx)->hasResult = DATA_SET_FLAG;
}
......
......@@ -100,6 +100,76 @@ if $data11 != -2 then
return -1
endi
print ==========>TD10758
sql create stable st(ts timestamp, c1 int) tags(t int);
sql create table ct1 using st tags(1)
sql insert into ct1 values(now, 1)(now+1s, 2)(now+2s, 3)
sql select csum(c1),ts,tbname,t from ct1
print $data10 , $data11 , $data12, $data13, $data14
if $data13 != ct1 then
return -1
endi
if $data14 != 1 then
return -1
endi
sql select csum(c1),ts,tbname,t from st group by tbname
print $data10 , $data11 , $data12, $data13, $data14
if $data13 != ct1 then
return -1
endi
if $data14 != 1 then
return -1
endi
sql select diff(c1),ts,tbname,t from ct1
print $data10 , $data11 , $data12, $data13, $data14
if $data13 != ct1 then
return -1
endi
if $data14 != 1 then
return -1
endi
sql select diff(c1),ts,tbname,t from st group by tbname
print $data10 , $data11 , $data12, $data13, $data14
if $data13 != ct1 then
return -1
endi
if $data14 != 1 then
return -1
endi
sql select mavg(c1,2),ts,tbname,t from ct1
print $data10 , $data11 , $data12, $data13, $data14
if $data13 != ct1 then
return -1
endi
if $data14 != 1 then
return -1
endi
sql select mavg(c1,2),ts,tbname,t from st group by tbname
print $data10 , $data11 , $data12, $data13, $data14
if $data13 != ct1 then
return -1
endi
if $data14 != 1 then
return -1
endi
sql select derivative(c1,1s,0),ts,tbname,t from ct1
print $data10 , $data11 , $data12, $data13, $data14
if $data13 != ct1 then
return -1
endi
if $data14 != 1 then
return -1
endi
sql select derivative(c1,1s,0),ts,tbname,t from st group by tbname
print $data10 , $data11 , $data12, $data13, $data14
if $data13 != ct1 then
return -1
endi
if $data14 != 1 then
return -1
endi
print =============== clear
sql drop database $db
sql show databases
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册