From 2261d689e4155515540beaa6866eae7ef93a4de6 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 29 Jul 2022 21:09:33 +0800 Subject: [PATCH] fix(query): opt read data from file block. --- source/dnode/vnode/src/tsdb/tsdbRead.c | 7 ++++--- source/libs/executor/src/executorimpl.c | 1 + tests/script/tsim/parser/function.sim | 4 +++- tests/script/tsim/parser/groupby.sim | 3 ++- tests/script/tsim/parser/limit_stb.sim | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index c5667cce41..072d15d715 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -2393,6 +2393,7 @@ int32_t doAppendRowFromBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBloc SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, i); if (pColData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) { colDataAppendInt64(pColData, outputRowIndex, &pBlockData->aTSKEY[rowIndex]); + i += 1; } SColVal cv = {0}; @@ -2404,8 +2405,8 @@ int32_t doAppendRowFromBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBloc SColData* pData = tBlockDataGetColDataByIdx(pBlockData, j); if (pData->cid == pCol->info.colId) { - tColDataGetValue(pData, j, &cv); - doCopyColVal(pCol, outputRowIndex++, i, &cv, pSupInfo); + tColDataGetValue(pData, rowIndex, &cv); + doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo); j += 1; } else { // the specified column does not exist in file block, fill with null data colDataAppendNULL(pCol, outputRowIndex); @@ -2416,7 +2417,7 @@ int32_t doAppendRowFromBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBloc while (i < numOfOutputCols) { SColumnInfoData* pCol = taosArrayGet(pResBlock->pDataBlock, i); - colDataAppendNULL(pCol, rowIndex); + colDataAppendNULL(pCol, outputRowIndex); i += 1; } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 46e1b198b6..064c747c88 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3355,6 +3355,7 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) { pOperator->numOfDownstream = 0; } + cleanupExprSupp(&pOperator->exprSupp); taosMemoryFreeClear(pOperator); } diff --git a/tests/script/tsim/parser/function.sim b/tests/script/tsim/parser/function.sim index cbfb59bcab..110901a6e1 100644 --- a/tests/script/tsim/parser/function.sim +++ b/tests/script/tsim/parser/function.sim @@ -500,11 +500,12 @@ if $rows != 2 then return -1 endi -sql select stddev(k), stddev(b), stddev(c),tbname, a from m1 group by tbname,a +sql select stddev(k), stddev(b), stddev(c),tbname, a from m1 group by tbname,a order by a asc if $rows != 2 then return -1 endi if $data00 != 1.414213562 then + print expect 1.414213562, actual: $data00 return -1 endi if $data01 != 14.142135624 then @@ -732,6 +733,7 @@ if $rows != 1 then return -1 endi if $data00 != 0.005633334 then + print expect 0.005633334, actual: $data00 return -1 endi diff --git a/tests/script/tsim/parser/groupby.sim b/tests/script/tsim/parser/groupby.sim index bf2c7cc7bf..c4c19ca211 100644 --- a/tests/script/tsim/parser/groupby.sim +++ b/tests/script/tsim/parser/groupby.sim @@ -681,12 +681,13 @@ if $data14 != 1 then return -1 endi -sql select _wstart, irate(c), tbname, t1, t2 from st where t1=1 and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' partition by tbname, t1, t2 interval(1m) sliding(15s) order by tbname desc limit 1; +sql select _wstart, irate(c), tbname, t1, t2 from st where t1=1 and ts >= '2020-03-27 04:11:17.732' and ts < '2020-03-27 05:11:17.732' partition by tbname, t1, t2 interval(1m) sliding(15s) order by tbname desc,_wstart asc limit 1; if $rows != 1 then return -1 endi if $data01 != 1.000000000 then + print expect 1.000000000, actual: $data01 return -1 endi if $data02 != t2 then diff --git a/tests/script/tsim/parser/limit_stb.sim b/tests/script/tsim/parser/limit_stb.sim index 0d0e4a8ea3..a0aff953cf 100644 --- a/tests/script/tsim/parser/limit_stb.sim +++ b/tests/script/tsim/parser/limit_stb.sim @@ -360,6 +360,7 @@ endi #sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 > 0 and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from lm_stb0 where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-09-17 10:30:00.000' and c1 > 1 and c2 < 9 and c3 > 2 and c4 < 8 and c5 > 3 and c6 < 7 and c7 = true and c8 like '%5' and t1 > 3 and t1 < 6 limit 1 offset 0; if $rows != 1 then + print expect 1, actual: $rows return -1 endi if $data00 != 5 then