Merge branch '3.0' into feature/TD-11274-3.0
This commit is contained in:
commit
0f7c2ebb01
|
@ -42,6 +42,7 @@ typedef struct SFillInfo {
|
|||
TSKEY start; // start timestamp
|
||||
TSKEY end; // endKey for fill
|
||||
TSKEY currentKey; // current active timestamp, the value may be changed during the fill procedure.
|
||||
int32_t tsSlotId; // primary time stamp slot id
|
||||
int32_t order; // order [TSDB_ORDER_ASC|TSDB_ORDER_DESC]
|
||||
int32_t type; // fill type
|
||||
int32_t numOfRows; // number of rows in the input data block
|
||||
|
@ -74,8 +75,8 @@ struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, co
|
|||
bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
|
||||
|
||||
SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
|
||||
SInterval* pInterval, int32_t fillType,
|
||||
struct SFillColInfo* pCol, const char* id);
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t slotId,
|
||||
const char* id);
|
||||
|
||||
void* taosDestroyFillInfo(struct SFillInfo *pFillInfo);
|
||||
int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, SSDataBlock* p, int32_t capacity);
|
||||
|
|
|
@ -4013,10 +4013,12 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
|
|||
w = getFirstQualifiedTimeWindow(win.skey, &w, pInterval, TSDB_ORDER_ASC);
|
||||
|
||||
int32_t order = TSDB_ORDER_ASC;
|
||||
pInfo->pFillInfo = taosCreateFillInfo(order, w.skey, 0, capacity, numOfCols, pInterval, fillType, pColInfo, id);
|
||||
pInfo->pFillInfo = taosCreateFillInfo(order, w.skey, 0, capacity, numOfCols, pInterval,
|
||||
fillType, pColInfo, pInfo->primaryTsCol, id);
|
||||
|
||||
pInfo->win = win;
|
||||
pInfo->p = taosMemoryCalloc(numOfCols, POINTER_BYTES);
|
||||
|
||||
if (pInfo->pFillInfo == NULL || pInfo->p == NULL) {
|
||||
taosMemoryFree(pInfo->pFillInfo);
|
||||
taosMemoryFree(pInfo->p);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
#include "os.h"
|
||||
#include "query.h"
|
||||
#include "taosdef.h"
|
||||
#include "tmsg.h"
|
||||
#include "ttypes.h"
|
||||
|
@ -48,14 +49,15 @@ static void setTagsValue(SFillInfo* pFillInfo, void** data, int32_t genRows) {
|
|||
}
|
||||
}
|
||||
|
||||
static void setNullRow(SSDataBlock* pBlock, int32_t numOfCol, int32_t rowIndex) {
|
||||
static void setNullRow(SSDataBlock* pBlock, int64_t ts, int32_t rowIndex) {
|
||||
// the first are always the timestamp column, so start from the second column.
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) {
|
||||
SColumnInfoData* p = taosArrayGet(pBlock->pDataBlock, i);
|
||||
if (p->info.type == TSDB_DATA_TYPE_TIMESTAMP && i == 0) {
|
||||
continue;
|
||||
if (p->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
colDataAppend(p, rowIndex, (const char*)&ts, false);
|
||||
} else {
|
||||
colDataAppendNULL(p, rowIndex);
|
||||
}
|
||||
colDataAppendNULL(p, rowIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,16 +66,17 @@ static void setNullRow(SSDataBlock* pBlock, int32_t numOfCol, int32_t rowIndex)
|
|||
|
||||
static void doSetVal(SColumnInfoData* pDstColInfoData, int32_t rowIndex, const SGroupKeys* pKey);
|
||||
|
||||
static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* pSrcBlock, int64_t ts,
|
||||
bool outOfBound) {
|
||||
static void doFillOneRow(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSDataBlock* pSrcBlock, int64_t ts,
|
||||
bool outOfBound) {
|
||||
SPoint point1, point2, point;
|
||||
int32_t step = GET_FORWARD_DIRECTION_FACTOR(pFillInfo->order);
|
||||
|
||||
// set the primary timestamp column value
|
||||
int32_t index = pFillInfo->numOfCurrent;
|
||||
SColumnInfoData* pCol0 = taosArrayGet(pBlock->pDataBlock, 0);
|
||||
SColumnInfoData* pCol0 = taosArrayGet(pBlock->pDataBlock, pFillInfo->tsSlotId);
|
||||
char* val = colDataGetData(pCol0, index);
|
||||
|
||||
// set the primary timestamp value
|
||||
*(TSKEY*)val = pFillInfo->currentKey;
|
||||
|
||||
// set the other values
|
||||
|
@ -92,7 +95,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSData
|
|||
}
|
||||
} else if (pFillInfo->type == TSDB_FILL_NEXT) {
|
||||
SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->next : pFillInfo->prev;
|
||||
|
||||
// todo refactor: start from 0 not 1
|
||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||
if (TSDB_COL_IS_TAG(pCol->flag)) {
|
||||
|
@ -106,7 +109,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSData
|
|||
} else if (pFillInfo->type == TSDB_FILL_LINEAR) {
|
||||
// TODO : linear interpolation supports NULL value
|
||||
if (outOfBound) {
|
||||
setNullRow(pBlock, pFillInfo->numOfCols, index);
|
||||
setNullRow(pBlock, pFillInfo->currentKey, index);
|
||||
} else {
|
||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||
|
@ -143,7 +146,7 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSData
|
|||
}
|
||||
}
|
||||
} else if (pFillInfo->type == TSDB_FILL_NULL) { // fill with NULL
|
||||
setNullRow(pBlock, pFillInfo->numOfCols, index);
|
||||
setNullRow(pBlock, pFillInfo->currentKey, index);
|
||||
} else { // fill with user specified value for each column
|
||||
for (int32_t i = 1; i < pFillInfo->numOfCols; ++i) {
|
||||
SFillColInfo* pCol = &pFillInfo->pFillCol[i];
|
||||
|
@ -166,6 +169,8 @@ static void doFillOneRowResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, SSData
|
|||
int64_t v = 0;
|
||||
GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i);
|
||||
colDataAppend(pDst, index, (char*)&v, false);
|
||||
} else if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
colDataAppend(pDst, index, (const char*)&pFillInfo->currentKey, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,7 +252,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t
|
|||
// fill the gap between two input rows
|
||||
while (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) &&
|
||||
pFillInfo->numOfCurrent < outputRows) {
|
||||
doFillOneRowResult(pFillInfo, pBlock, pFillInfo->pSrcBlock, ts, false);
|
||||
doFillOneRow(pFillInfo, pBlock, pFillInfo->pSrcBlock, ts, false);
|
||||
}
|
||||
|
||||
// output buffer is full, abort
|
||||
|
@ -343,7 +348,7 @@ static int64_t appendFilledResult(SFillInfo* pFillInfo, SSDataBlock* pBlock, int
|
|||
*/
|
||||
pFillInfo->numOfCurrent = 0;
|
||||
while (pFillInfo->numOfCurrent < resultCapacity) {
|
||||
doFillOneRowResult(pFillInfo, pBlock, pFillInfo->pSrcBlock, pFillInfo->start, true);
|
||||
doFillOneRow(pFillInfo, pBlock, pFillInfo->pSrcBlock, pFillInfo->start, true);
|
||||
}
|
||||
|
||||
pFillInfo->numOfTotal += pFillInfo->numOfCurrent;
|
||||
|
@ -408,7 +413,7 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
|
|||
}
|
||||
|
||||
struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol,
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t primaryTsSlotId,
|
||||
const char* id) {
|
||||
if (fillType == TSDB_FILL_NONE) {
|
||||
return NULL;
|
||||
|
@ -420,6 +425,8 @@ struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTag
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pFillInfo->tsSlotId = primaryTsSlotId;
|
||||
|
||||
taosResetFillInfo(pFillInfo, skey);
|
||||
pFillInfo->order = order;
|
||||
|
||||
|
@ -589,11 +596,10 @@ int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, SSDataBlock* p, int32_t ca
|
|||
assert(numOfRes == pFillInfo->numOfCurrent);
|
||||
}
|
||||
|
||||
// qDebug("fill:%p, generated fill result, src block:%d, index:%d, brange:%"PRId64"-%"PRId64", currentKey:%"PRId64",
|
||||
// current:%d, total:%d, %p",
|
||||
// pFillInfo, pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey,
|
||||
// pFillInfo->numOfCurrent,
|
||||
// pFillInfo->numOfTotal, pFillInfo->handle);
|
||||
qDebug("fill:%p, generated fill result, src block:%d, index:%d, brange:%" PRId64 "-%" PRId64 ", currentKey:%" PRId64
|
||||
", current : % d, total : % d, %s", pFillInfo,
|
||||
pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey,
|
||||
pFillInfo->numOfCurrent, pFillInfo->numOfTotal, pFillInfo->id);
|
||||
|
||||
return numOfRes;
|
||||
}
|
||||
|
|
|
@ -162,12 +162,11 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
|
|||
}
|
||||
|
||||
if (NULL == pScanCols) {
|
||||
// select count(*) from t
|
||||
return NULL == pScanPseudoCols
|
||||
? SCAN_TYPE_TABLE
|
||||
: ((FUNCTION_TYPE_BLOCK_DIST_INFO == ((SFunctionNode*)nodesListGetNode(pScanPseudoCols, 0))->funcType)
|
||||
? SCAN_TYPE_BLOCK_INFO
|
||||
: SCAN_TYPE_TAG);
|
||||
: SCAN_TYPE_TABLE);
|
||||
}
|
||||
|
||||
if (TSDB_SYSTEM_TABLE == tableType) {
|
||||
|
@ -181,7 +180,7 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
|
|||
}
|
||||
}
|
||||
|
||||
return SCAN_TYPE_TAG;
|
||||
return SCAN_TYPE_TABLE;
|
||||
}
|
||||
|
||||
static SNode* createPrimaryKeyCol(uint64_t tableId) {
|
||||
|
|
|
@ -538,9 +538,9 @@ class TDTestCase:
|
|||
tdSql.query("select c1 ,t1 from stb1 where t1 =0 ")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.query("select t1 from stb1 where t1 >0 ")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkRows(12)
|
||||
tdSql.query("select t1 from stb1 where t1 =3 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkRows(12)
|
||||
# tdSql.query("select sum(t1) from (select c1 ,t1 from stb1)")
|
||||
# tdSql.checkData(0,0,61)
|
||||
# tdSql.query("select distinct(c1) ,t1 from stb1")
|
||||
|
@ -550,7 +550,7 @@ class TDTestCase:
|
|||
|
||||
# tag filter with abs function
|
||||
tdSql.query("select t1 from stb1 where abs(t1)=1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select t1 from stb1 where abs(c1+t1)=1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,0)
|
||||
|
|
|
@ -495,9 +495,9 @@ class TDTestCase:
|
|||
tdSql.checkRows(13)
|
||||
self.check_function("&", False ,"t1","c1+2","abs(c2)")
|
||||
tdSql.query("select t1 from stb1 where t1 >0 ")
|
||||
tdSql.checkRows(3)
|
||||
tdSql.checkRows(12)
|
||||
tdSql.query("select t1 from stb1 where t1 =3 ")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkRows(12)
|
||||
# tdSql.query("select sum(t1) from (select c1 ,t1 from stb1)")
|
||||
# tdSql.checkData(0,0,61)
|
||||
# tdSql.query("select distinct(c1) ,t1 from stb1")
|
||||
|
@ -507,7 +507,7 @@ class TDTestCase:
|
|||
|
||||
# tag filter with abs function
|
||||
tdSql.query("select t1 from stb1 where abs(t1)=1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkRows(0)
|
||||
tdSql.query("select t1 from stb1 where abs(c1+t1)=1")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.checkData(0,0,0)
|
||||
|
|
|
@ -57,7 +57,7 @@ class TDTestCase:
|
|||
# test duplicate key using the first one. elimate empty key
|
||||
tdSql.execute("CREATE TABLE if not exists jsons1_8 using jsons1 tags('{\"tag1\":null, \"tag1\":true, \"tag1\":45, \"1tag$\":2, \" \":90, \"\":32}')")
|
||||
tdSql.query("select jtag from jsons1_8")
|
||||
tdSql.checkData(0, 0, '{" ":90,"1tag$":2,"tag1":null}')
|
||||
tdSql.checkRows(0);
|
||||
|
||||
tdSql.query("select ts,jtag from jsons1 order by ts limit 2,3")
|
||||
tdSql.checkData(0, 0, '2020-06-02 09:17:08.000')
|
||||
|
@ -153,38 +153,17 @@ class TDTestCase:
|
|||
|
||||
#test scalar operation
|
||||
tdSql.query("select jtag contains 'tag1',jtag->'tag1' from jsons1 order by jtag->'tag1'")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkData(0, 0, False)
|
||||
tdSql.checkData(5, 0, True)
|
||||
tdSql.checkData(12, 0, True)
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query("select jtag->'tag1' like 'fe%',jtag->'tag1' from jsons1 order by jtag->'tag1'")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkData(10, 0, False)
|
||||
tdSql.checkData(11, 0, False)
|
||||
tdSql.checkData(12, 0, True)
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query("select jtag->'tag1' not like 'fe%',jtag->'tag1' from jsons1 order by jtag->'tag1'")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkData(10, 0, False)
|
||||
tdSql.checkData(11, 0, True)
|
||||
tdSql.checkData(12, 0, False)
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query("select jtag->'tag1' match 'fe',jtag->'tag1' from jsons1 order by jtag->'tag1'")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkData(10, 0, False)
|
||||
tdSql.checkData(11, 0, False)
|
||||
tdSql.checkData(12, 0, True)
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query("select jtag->'tag1' nmatch 'fe',jtag->'tag1' from jsons1 order by jtag->'tag1'")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkData(10, 0, False)
|
||||
tdSql.checkData(11, 0, True)
|
||||
tdSql.checkData(12, 0, False)
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query("select jtag->'tag1',jtag->'tag1'>='a' from jsons1 order by jtag->'tag1'")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkData(0, 1, False)
|
||||
tdSql.checkData(7, 0, "false")
|
||||
tdSql.checkData(7, 1, False)
|
||||
tdSql.checkData(8, 1, False)
|
||||
tdSql.checkData(12, 1, True)
|
||||
tdSql.checkRows(9)
|
||||
|
||||
# test select normal column
|
||||
tdSql.query("select dataint from jsons1 order by dataint")
|
||||
|
@ -195,7 +174,7 @@ class TDTestCase:
|
|||
tdSql.query("select * from jsons1")
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query("select jtag from jsons1")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkRows(9)
|
||||
tdSql.query("select * from jsons1 where jtag is null")
|
||||
tdSql.checkRows(1)
|
||||
tdSql.query("select * from jsons1 where jtag is not null")
|
||||
|
@ -227,7 +206,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 0, None)
|
||||
|
||||
tdSql.query("select jtag->'tag1' from jsons1")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.checkRows(9)
|
||||
# test header name
|
||||
res = tdSql.getColNameList("select jtag->'tag1' from jsons1")
|
||||
cname_list = []
|
||||
|
@ -415,7 +394,7 @@ class TDTestCase:
|
|||
# test distinct
|
||||
tdSql.execute("insert into jsons1_14 using jsons1 tags('{\"tag1\":\"收到货\",\"tag2\":\"\",\"tag3\":null}') values(1591062628000, 2, NULL, '你就会', 'dws')")
|
||||
tdSql.query("select distinct jtag->'tag1' from jsons1")
|
||||
tdSql.checkRows(8)
|
||||
tdSql.checkRows(7)
|
||||
# tdSql.query("select distinct jtag from jsons1")
|
||||
# tdSql.checkRows(9)
|
||||
|
||||
|
@ -523,12 +502,12 @@ class TDTestCase:
|
|||
|
||||
# union all
|
||||
tdSql.query("select jtag->'tag1' from jsons1 union all select jtag->'tag2' from jsons2")
|
||||
tdSql.checkRows(17)
|
||||
tdSql.checkRows(13)
|
||||
tdSql.query("select jtag->'tag1' from jsons1_1 union all select jtag->'tag2' from jsons2_1")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkRows(3)
|
||||
|
||||
tdSql.query("select jtag->'tag1' from jsons1_1 union all select jtag->'tag1' from jsons2_1")
|
||||
tdSql.checkRows(2)
|
||||
tdSql.checkRows(3)
|
||||
tdSql.query("select dataint,jtag->'tag1',tbname from jsons1 union all select dataint,jtag->'tag1',tbname from jsons2")
|
||||
tdSql.checkRows(13)
|
||||
tdSql.query("select dataint,jtag,tbname from jsons1 union all select dataint,jtag,tbname from jsons2")
|
||||
|
@ -709,7 +688,7 @@ class TDTestCase:
|
|||
tdSql.checkData(0, 0, None)
|
||||
tdSql.execute("CREATE TABLE if not exists jsons1_20 using jsons1 tags(NULL)")
|
||||
tdSql.query("select jtag from jsons1_20")
|
||||
tdSql.checkData(0, 0, None)
|
||||
tdSql.checkRows(0)
|
||||
tdSql.execute("insert into jsons1_21 using jsons1 tags(NULL) values(1591061628000, 11, false, '你就会','')")
|
||||
tdSql.query("select jtag from jsons1_21")
|
||||
tdSql.checkData(0, 0, None)
|
||||
|
|
Loading…
Reference in New Issue