feat: [TS-4897] Add more test and fix bugs. (#30208)

* feat: [TS-4897] Fix state window wrong res when all state col is NULL.

* fix: [TD-34074] Forbid decimal type in virtual table.
This commit is contained in:
Jing Sima 2025-03-19 17:15:17 +08:00 committed by GitHub
parent 77f9707f89
commit ccaa0b91ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 990 additions and 2828 deletions

View File

@ -560,8 +560,9 @@ This document details the server error codes that may be encountered when using
## virtual table
| Error Code | Description | Possible Error Scenarios or Reasons | Recommended Actions for Users |
|-------------|---------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------|
|------------|---------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| 0x80006200 | Virtual table scan internal error | virtual table scan operator internal error, generally does not occur | Check error logs, contact development for handling |
| 0x80006201 | Virtual table scan invalid downstream operator type | The incorrect execution plan generated causes the downstream operator type of the virtual table scan operator to be incorrect. | Check error logs, contact development for handling |
| 0x80006202 | Virtual table prim timestamp column should not has ref | The timestamp primary key column of a virtual table should not have a data source. If it does, this error will occur during subsequent queries on the virtual table. | Check error logs, contact development for handling |
| 0x80006203 | Create virtual child table must use virtual super table | Create virtual child table using non-virtual super table | create virtual child table using virtual super table |
| 0x80006204 | Virtual table not support decimal type | Create virtual table using decimal type | create virtual table without using decimal type |

View File

@ -579,9 +579,10 @@ description: TDengine 服务端的错误码列表和详细说明
## virtual table
| 错误码 | 错误描述 | 可能的出错场景或者可能的原因 | 建议用户采取的措施 |
|------------|---------------------------------------------------------|------------------------------------------------|------------------------|
|------------|---------------------------------------------------------|------------------------------------------------|----------------------------|
| 0x80006200 | Virtual table scan 算子内部错误 | virtual table scan 算子内部逻辑错误,一般不会出现 | 具体查看client端的错误日志提示 |
| 0x80006201 | Virtual table scan invalid downstream operator type | 由于生成的执行计划不对,导致 virtual table scan 算子的下游算子类型不正确 | 保留 explain 执行计划,联系开发处理 |
| 0x80006202 | Virtual table prim timestamp column should not has ref | 虚拟表的时间戳主键列不应该有数据源,如果有,后续查询虚拟表的时候就会出现该错误 | 检查错误日志,联系开发处理 |
| 0x80006203 | Create virtual child table must use virtual super table | 虚拟子表必须建在虚拟超级表下,否则就会出现该错误 | 创建虚拟子表的时候USING 虚拟超级表 |
| 0x80006204 | Virtual table not support decimal type | 虚拟表不支持 decimal 类型 | 创建虚拟表时不使用 decimal 类型的列/tag |

View File

@ -54,6 +54,8 @@ const char* tNameGetDbNameP(const SName* name);
int32_t tNameGetFullDbName(const SName* name, char* dst);
int32_t tNameGetFullTableName(const SName* name, char* dst);
bool tNameIsEmpty(const SName* name);
void tNameAssign(SName* dst, const SName* src);

View File

@ -134,6 +134,8 @@ int32_t qUpdateTableListForStreamScanner(qTaskInfo_t tinfo, const SArray* tableI
bool qIsDynamicExecTask(qTaskInfo_t tinfo);
void qDestroyOperatorParam(SOperatorParam* pParam);
void qUpdateOperatorParam(qTaskInfo_t tinfo, void* pParam);
/**

View File

@ -1070,6 +1070,7 @@ int32_t taosGetErrSize();
#define TSDB_CODE_VTABLE_SCAN_INVALID_DOWNSTREAM TAOS_DEF_ERROR_CODE(0, 0x6201)
#define TSDB_CODE_VTABLE_PRIMTS_HAS_REF TAOS_DEF_ERROR_CODE(0, 0x6202)
#define TSDB_CODE_VTABLE_NOT_VIRTUAL_SUPER_TABLE TAOS_DEF_ERROR_CODE(0, 0x6203)
#define TSDB_CODE_VTABLE_NOT_SUPPORT_DATA_TYPE TAOS_DEF_ERROR_CODE(0, 0x6204)
#ifdef __cplusplus
}
#endif

View File

@ -9486,10 +9486,11 @@ int32_t tDeserializeSOperatorParam(SDecoder *pDecoder, SOperatorParam *pOpParam)
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pOpParam->downstreamIdx));
switch (pOpParam->opType) {
case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: {
STableScanOperatorParam *pScan = taosMemoryMalloc(sizeof(STableScanOperatorParam));
if (NULL == pScan) {
pOpParam->value = taosMemoryMalloc(sizeof(STableScanOperatorParam));
if (NULL == pOpParam->value) {
TAOS_CHECK_RETURN(terrno);
}
STableScanOperatorParam *pScan = pOpParam->value;
TAOS_CHECK_RETURN(tDecodeI8(pDecoder, (int8_t *)&pScan->tableSeq));
int32_t uidNum = 0;
int64_t uid = 0;
@ -9535,8 +9536,6 @@ int32_t tDeserializeSOperatorParam(SDecoder *pDecoder, SOperatorParam *pOpParam)
}
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pScan->window.skey));
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pScan->window.ekey));
pOpParam->value = pScan;
break;
}
default:

View File

@ -104,6 +104,14 @@ const char* tNameGetTableName(const SName* name) {
return &name->tname[0];
}
int32_t tNameGetFullTableName(const SName* name, char* dst) {
if (name == NULL || dst == NULL) {
return TSDB_CODE_INVALID_PARA;
}
(void)snprintf(dst, TSDB_TABLE_FNAME_LEN, "%s.%s", name->dbname, name->tname);
return 0;
}
void tNameAssign(SName* dst, const SName* src) { memcpy(dst, src, sizeof(SName)); }
int32_t tNameSetDbName(SName* dst, int32_t acct, const char* dbName, size_t nameLen) {
@ -230,7 +238,7 @@ static int compareKv(const void* p1, const void* p2) {
}
/*
* use stable name and tags to grearate child table name
* use stable name and tags to generate child table name
*/
int32_t buildChildTableName(RandTableName* rName) {
taosArraySort(rName->tags, compareKv);

View File

@ -202,6 +202,7 @@ _return:
int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta) {
int32_t code = 0;
int32_t line = 0;
STableMetaOutput* output = NULL;
CTG_ERR_RET(ctgGetTbMetaFromCache(pCtg, ctx, pTableMeta));
@ -224,7 +225,7 @@ int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx
goto _return;
}
if (CTG_IS_META_VBOTH(output->metaType) || CTG_IS_META_VCTABLE(output->metaType)) {
if (CTG_IS_META_VBOTH(output->metaType)) {
int32_t colRefSize = output->vctbMeta->numOfColRefs * sizeof(SColRef);
if (output->tbMeta) {
int32_t metaSize = CTG_META_SIZE(output->tbMeta);
@ -246,17 +247,14 @@ int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx
goto _return;
}
if ((!CTG_IS_META_CTABLE(output->metaType)) || output->tbMeta) {
if ((!CTG_IS_META_CTABLE(output->metaType) && !CTG_IS_META_VCTABLE(output->metaType)) || output->tbMeta) {
ctgError("invalid metaType:%d", output->metaType);
taosMemoryFreeClear(output->vctbMeta);
taosMemoryFreeClear(output->tbMeta);
CTG_ERR_JRET(TSDB_CODE_CTG_INTERNAL_ERROR);
}
// HANDLE ONLY CHILD TABLE META
taosMemoryFreeClear(output->tbMeta);
taosMemoryFreeClear(output->vctbMeta);
// HANDLE ONLY (VIRTUAL) CHILD TABLE META
SName stbName = *ctx->pName;
TAOS_STRCPY(stbName.tname, output->tbName);
@ -269,8 +267,21 @@ int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx
ctgDebug("tb:%s, stb no longer exist, db:%s", ctx->pName->tname, output->dbFName);
continue;
}
if (CTG_IS_META_CTABLE(output->metaType)) {
TAOS_MEMCPY(*pTableMeta, &output->ctbMeta, sizeof(output->ctbMeta));
} else if (CTG_IS_META_VCTABLE(output->metaType)) {
int32_t colRefSize = output->vctbMeta->numOfColRefs * sizeof(SColRef);
int32_t metaSize = CTG_META_SIZE(*pTableMeta);
(*pTableMeta) = taosMemoryRealloc(*pTableMeta, metaSize + colRefSize);
QUERY_CHECK_NULL(*pTableMeta, code , line, _return, terrno);
TAOS_MEMCPY(*pTableMeta, output->vctbMeta, sizeof(SVCTableMeta));
(*pTableMeta)->colRef = (SColRef *)((char *)(*pTableMeta) + metaSize);
TAOS_MEMCPY((*pTableMeta)->colRef, output->vctbMeta->colRef, colRefSize);
(*pTableMeta)->numOfColRefs = output->vctbMeta->numOfColRefs;
}
taosMemoryFreeClear(output->tbMeta);
taosMemoryFreeClear(output->vctbMeta);
break;
}

View File

@ -75,20 +75,20 @@ typedef struct SStbJoinDynCtrlInfo {
} SStbJoinDynCtrlInfo;
typedef struct SVtbScanDynCtrlInfo {
int32_t acctId;
SUseDbRsp* pRsp;
SUseDbReq req;
bool scanAllCols;
tsem_t ready;
SEpSet epSet;
SUseDbRsp* pRsp;
uint64_t suid;
SReadHandle readHandle;
SArray* childTableList;
int32_t acctId;
int32_t curTableIdx;
int32_t lastTableIdx;
SOperatorParam* vtbScanParam;
int32_t readTableIdx;
SHashObj* dbVgInfoMap;
SArray* readColList;
bool scanAllCols;
SArray* childTableList;
SHashObj* dbVgInfoMap;
SHashObj* orgTbVgColMap;
SReadHandle readHandle;
SOperatorParam* vtbScanParam;
} SVtbScanDynCtrlInfo;
typedef struct SDynQueryCtrlOperatorInfo {

View File

@ -80,6 +80,13 @@ static void destroyStbJoinDynCtrlInfo(SStbJoinDynCtrlInfo* pStbJoin) {
destroyStbJoinTableList(pStbJoin->ctx.prev.pListHead);
}
void destroyOrgTbInfo(void *info) {
SOrgTbInfo *pOrgTbInfo = (SOrgTbInfo *)info;
if (pOrgTbInfo) {
taosArrayDestroy(pOrgTbInfo->colMap);
}
}
void freeUseDbOutput(void* pOutput) {
SUseDbOutput *pOut = *(SUseDbOutput**)pOutput;
if (NULL == pOutput) {
@ -103,6 +110,10 @@ static void destroyVtbScanDynCtrlInfo(SVtbScanDynCtrlInfo* pVtbScan) {
taosHashSetFreeFp(pVtbScan->dbVgInfoMap, freeUseDbOutput);
taosHashCleanup(pVtbScan->dbVgInfoMap);
}
if (pVtbScan->orgTbVgColMap) {
taosHashSetFreeFp(pVtbScan->orgTbVgColMap, destroyOrgTbInfo);
taosHashCleanup(pVtbScan->orgTbVgColMap);
}
if (pVtbScan->pRsp) {
tFreeSUsedbRsp(pVtbScan->pRsp);
taosMemoryFreeClear(pVtbScan->pRsp);
@ -1071,7 +1082,7 @@ _return:
return code;
}
static int32_t buildVtbScanOperatorParam(SDynQueryCtrlOperatorInfo* pInfo, SOperatorParam** ppRes) {
static int32_t buildVtbScanOperatorParam(SDynQueryCtrlOperatorInfo* pInfo, SOperatorParam** ppRes, uint64_t uid) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
SVTableScanOperatorParam* pVScan = NULL;
@ -1085,6 +1096,7 @@ static int32_t buildVtbScanOperatorParam(SDynQueryCtrlOperatorInfo* pInfo, SOper
QUERY_CHECK_NULL(pVScan, code, lino, _return, terrno);
pVScan->pOpParamArray = taosArrayInit(1, POINTER_BYTES);
QUERY_CHECK_NULL(pVScan->pOpParamArray, code, lino, _return, terrno);
pVScan->uid = uid;
(*ppRes)->opType = QUERY_NODE_PHYSICAL_PLAN_VIRTUAL_TABLE_SCAN;
(*ppRes)->downstreamIdx = 0;
@ -1283,11 +1295,32 @@ bool colNeedScan(SOperatorInfo* pOperator, col_id_t colId) {
return false;
}
void destroyOrgTbInfo(void *info) {
SOrgTbInfo *pOrgTbInfo = (SOrgTbInfo *)info;
if (pOrgTbInfo) {
taosArrayDestroy(pOrgTbInfo->colMap);
int32_t getDbVgInfo(SOperatorInfo* pOperator, SName *name, SDBVgInfo **dbVgInfo) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t line = 0;
SDynQueryCtrlOperatorInfo* pInfo = pOperator->info;
SVtbScanDynCtrlInfo* pVtbScan = (SVtbScanDynCtrlInfo*)&pInfo->vtbScan;
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SReadHandle* pHandle = &pVtbScan->readHandle;
SUseDbOutput* output = NULL;
SUseDbOutput** find = (SUseDbOutput**)taosHashGet(pInfo->vtbScan.dbVgInfoMap, name->dbname, strlen(name->dbname));
QRY_PARAM_CHECK(dbVgInfo);
if (find == NULL) {
output = taosMemoryMalloc(sizeof(SUseDbOutput));
QUERY_CHECK_CODE(buildDbVgInfoMap(pOperator, pHandle, name, pTaskInfo, output), line, _return);
QUERY_CHECK_CODE(taosHashPut(pInfo->vtbScan.dbVgInfoMap, name->dbname, strlen(name->dbname), &output, POINTER_BYTES), line, _return);
} else {
output = *find;
}
*dbVgInfo = output->dbVgroup;
return code;
_return:
qError("%s failed at line %d since %s", __func__, line, tstrerror(code));
freeUseDbOutput(output);
return code;
}
int32_t vtbScan(SOperatorInfo* pOperator, SSDataBlock** pRes) {
@ -1298,7 +1331,7 @@ int32_t vtbScan(SOperatorInfo* pOperator, SSDataBlock** pRes) {
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SReadHandle* pHandle = &pVtbScan->readHandle;
SMetaReader mr = {0};
SHashObj* orgTbVgColMap = NULL;
SDBVgInfo* dbVgInfo = NULL;
QRY_PARAM_CHECK(pRes);
if (pOperator->status == OP_EXEC_DONE) {
@ -1312,21 +1345,21 @@ int32_t vtbScan(SOperatorInfo* pOperator, SSDataBlock** pRes) {
size_t num = taosArrayGetSize(pVtbScan->childTableList);
// no child table, return
if (num == 0) {
setOperatorCompleted(pOperator);
return code;
}
// TODO(smj) : proper hash size
orgTbVgColMap = taosHashInit(num * 64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
QUERY_CHECK_NULL(orgTbVgColMap, code, line, _return, terrno);
taosHashSetFreeFp(orgTbVgColMap, destroyOrgTbInfo);
pVtbScan->orgTbVgColMap = taosHashInit(num * 64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
QUERY_CHECK_NULL(pVtbScan->orgTbVgColMap, code, line, _return, terrno);
taosHashSetFreeFp(pVtbScan->orgTbVgColMap, destroyOrgTbInfo);
while (true) {
if (pVtbScan->readTableIdx == pVtbScan->lastTableIdx) {
if (pVtbScan->curTableIdx == pVtbScan->lastTableIdx) {
QUERY_CHECK_CODE(pOperator->pDownstream[0]->fpSet.getNextFn(pOperator->pDownstream[0], pRes), line, _return);
} else {
uint64_t* id = taosArrayGet(pVtbScan->childTableList, pVtbScan->readTableIdx);
uint64_t* id = taosArrayGet(pVtbScan->childTableList, pVtbScan->curTableIdx);
QUERY_CHECK_NULL(id, code, line, _return, terrno);
pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, META_READER_LOCK, &pHandle->api.metaFn);
QUERY_CHECK_CODE(pHandle->api.metaReaderFn.getTableEntryByUid(&mr, *id), line, _return);
@ -1334,29 +1367,18 @@ int32_t vtbScan(SOperatorInfo* pOperator, SSDataBlock** pRes) {
for (int32_t j = 0; j < mr.me.colRef.nCols; j++) {
if (mr.me.colRef.pColRef[j].hasRef && colNeedScan(pOperator, mr.me.colRef.pColRef[j].id)) {
SName name = {0};
toName(pInfo->vtbScan.acctId, mr.me.colRef.pColRef[j].refDbName, "", &name);
SUseDbOutput* output = NULL;
SUseDbOutput** find = (SUseDbOutput**)taosHashGet(pInfo->vtbScan.dbVgInfoMap, name.dbname, strlen(name.dbname));
if (find == NULL) {
output = taosMemoryMalloc(sizeof(SUseDbOutput));
QUERY_CHECK_CODE(buildDbVgInfoMap(pOperator, pHandle, &name, pTaskInfo, output), line, _return);
QUERY_CHECK_CODE(taosHashPut(pInfo->vtbScan.dbVgInfoMap, name.dbname, strlen(name.dbname), &output, sizeof(output)), line, _return);
} else {
output = *find;
}
int32_t vgId = 0;
char dbFname[TSDB_DB_FNAME_LEN] = {0};
QUERY_CHECK_CODE(tNameGetFullDbName(&name, dbFname), line, _return);
QUERY_CHECK_CODE(getVgId(output->dbVgroup, dbFname, &vgId, mr.me.colRef.pColRef[j].refTableName), line, _return);
char orgTbFName[TSDB_TABLE_FNAME_LEN] = {0};
TAOS_STRNCAT(orgTbFName, mr.me.colRef.pColRef[j].refDbName, TSDB_DB_NAME_LEN);
TAOS_STRNCAT(orgTbFName, ".", 2);
TAOS_STRNCAT(orgTbFName, mr.me.colRef.pColRef[j].refTableName, TSDB_TABLE_NAME_LEN);
void *tbVgCol = taosHashGet(orgTbVgColMap, orgTbFName, sizeof(orgTbFName));
if (!tbVgCol) {
toName(pInfo->vtbScan.acctId, mr.me.colRef.pColRef[j].refDbName, mr.me.colRef.pColRef[j].refTableName, &name);
QUERY_CHECK_CODE(getDbVgInfo(pOperator, &name, &dbVgInfo), line, _return);
QUERY_CHECK_CODE(tNameGetFullDbName(&name, dbFname), line, _return);
QUERY_CHECK_CODE(tNameGetFullTableName(&name, orgTbFName), line, _return);
void *pVal = taosHashGet(pVtbScan->orgTbVgColMap, orgTbFName, sizeof(orgTbFName));
if (!pVal) {
SOrgTbInfo map = {0};
map.vgId = vgId;
QUERY_CHECK_CODE(getVgId(dbVgInfo, dbFname, &map.vgId, name.tname), line, _return);
tstrncpy(map.tbName, orgTbFName, sizeof(map.tbName));
map.colMap = taosArrayInit(10, sizeof(SColIdNameKV));
QUERY_CHECK_NULL(map.colMap, code, line, _return, terrno);
@ -1364,40 +1386,43 @@ int32_t vtbScan(SOperatorInfo* pOperator, SSDataBlock** pRes) {
colIdNameKV.colId = mr.me.colRef.pColRef[j].id;
tstrncpy(colIdNameKV.colName, mr.me.colRef.pColRef[j].refColName, sizeof(colIdNameKV.colName));
QUERY_CHECK_NULL(taosArrayPush(map.colMap, &colIdNameKV), code, line, _return, terrno);
QUERY_CHECK_CODE(taosHashPut(orgTbVgColMap, orgTbFName, sizeof(orgTbFName), &map, sizeof(map)), line, _return);
QUERY_CHECK_CODE(taosHashPut(pVtbScan->orgTbVgColMap, orgTbFName, sizeof(orgTbFName), &map, sizeof(map)), line, _return);
} else {
SOrgTbInfo *map = (SOrgTbInfo *)tbVgCol;
SOrgTbInfo *tbInfo = (SOrgTbInfo *)pVal;
SColIdNameKV colIdNameKV = {0};
colIdNameKV.colId = mr.me.colRef.pColRef[j].id;
tstrncpy(colIdNameKV.colName, mr.me.colRef.pColRef[j].refColName, sizeof(colIdNameKV.colName));
QUERY_CHECK_NULL(taosArrayPush(map->colMap, &colIdNameKV), code, line, _return, terrno);
QUERY_CHECK_NULL(taosArrayPush(tbInfo->colMap, &colIdNameKV), code, line, _return, terrno);
}
}
}
pVtbScan->vtbScanParam = NULL;
QUERY_CHECK_CODE(buildVtbScanOperatorParam(pInfo, &pVtbScan->vtbScanParam), line, _return);
((SVTableScanOperatorParam*)pVtbScan->vtbScanParam->value)->uid = *id;
QUERY_CHECK_CODE(buildVtbScanOperatorParam(pInfo, &pVtbScan->vtbScanParam, *id), line, _return);
void* pIter = taosHashIterate(orgTbVgColMap, NULL);
void* pIter = taosHashIterate(pVtbScan->orgTbVgColMap, NULL);
while (pIter != NULL) {
SOrgTbInfo* pMap = (SOrgTbInfo*)pIter;
SOperatorParam* pExchangeParam = NULL;
QUERY_CHECK_CODE(buildExchangeOperatorParamForVScan(&pExchangeParam, 0, pMap), line, _return);
QUERY_CHECK_NULL(taosArrayPush(((SVTableScanOperatorParam*)pVtbScan->vtbScanParam->value)->pOpParamArray, &pExchangeParam), code, line, _return, terrno);
pIter = taosHashIterate(orgTbVgColMap, pIter);
pIter = taosHashIterate(pVtbScan->orgTbVgColMap, pIter);
}
pHandle->api.metaReaderFn.clearReader(&mr);
// reset downstream operator's status
pOperator->pDownstream[0]->status = OP_NOT_OPENED;
QUERY_CHECK_CODE(pOperator->pDownstream[0]->fpSet.getNextExtFn(pOperator->pDownstream[0], pVtbScan->vtbScanParam, pRes), line, _return);
}
if (*pRes) {
pVtbScan->lastTableIdx = pVtbScan->readTableIdx;
// has result, still read data from this table.
pVtbScan->lastTableIdx = pVtbScan->curTableIdx;
break;
} else {
pVtbScan->readTableIdx++;
if (pVtbScan->readTableIdx >= taosArrayGetSize(pVtbScan->childTableList)) {
// no result, read next table.
pVtbScan->curTableIdx++;
if (pVtbScan->curTableIdx >= taosArrayGetSize(pVtbScan->childTableList)) {
setOperatorCompleted(pOperator);
break;
}
@ -1405,7 +1430,8 @@ int32_t vtbScan(SOperatorInfo* pOperator, SSDataBlock** pRes) {
}
_return:
taosHashCleanup(orgTbVgColMap);
taosHashCleanup(pVtbScan->orgTbVgColMap);
pVtbScan->orgTbVgColMap = NULL;
if (pOperator->cost.openCost == 0) {
pOperator->cost.openCost = (double)(taosGetTimestampUs() - st) / 1000.0;
}
@ -1459,7 +1485,7 @@ static int32_t initVtbScanInfo(SOperatorInfo* pOperator, SDynQueryCtrlOperatorIn
pInfo->vtbScan.epSet = pPhyciNode->vtbScan.mgmtEpSet;
pInfo->vtbScan.acctId = pPhyciNode->vtbScan.accountId;
pInfo->vtbScan.readHandle = *pHandle;
pInfo->vtbScan.readTableIdx = 0;
pInfo->vtbScan.curTableIdx = 0;
pInfo->vtbScan.lastTableIdx = -1;
pInfo->vtbScan.readColList = taosArrayInit(LIST_LENGTH(pPhyciNode->vtbScan.pScanCols), sizeof(col_id_t));
@ -1472,12 +1498,17 @@ static int32_t initVtbScanInfo(SOperatorInfo* pOperator, SDynQueryCtrlOperatorIn
}
pInfo->vtbScan.childTableList = taosArrayInit(10, sizeof(uint64_t));
QUERY_CHECK_NULL(pInfo->vtbScan.childTableList, code, line, _return, terrno);
QUERY_CHECK_CODE(pHandle->api.metaFn.getChildTableList(pHandle->vnode, pInfo->vtbScan.suid, pInfo->vtbScan.childTableList), line, _return);
pInfo->vtbScan.dbVgInfoMap = taosHashInit(taosArrayGetSize(pInfo->vtbScan.childTableList), taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
QUERY_CHECK_NULL(pInfo->vtbScan.dbVgInfoMap, code, line, _return, terrno);
return code;
_return:
// no need to destroy array and hashmap allocated in this function,
// since the operator's destroy function will take care of it
qError("%s failed at line %d since %s", __func__, line, tstrerror(code));
return code;
}

View File

@ -626,6 +626,13 @@ void destroyOperatorParam(SOperatorParam* pParam) {
// TODO
}
void qDestroyOperatorParam(SOperatorParam* pParam) {
if (NULL == pParam) {
return;
}
freeOperatorParam(pParam, OP_GET_PARAM);
}
void qUpdateOperatorParam(qTaskInfo_t tinfo, void* pParam) {
destroyOperatorParam(((SExecTaskInfo*)tinfo)->pOpParam);
((SExecTaskInfo*)tinfo)->pOpParam = pParam;

View File

@ -967,6 +967,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
}
int64_t gid = pBlock->info.id.groupId;
bool hasResult = false;
bool masterScan = true;
int32_t numOfOutput = pOperator->exprSupp.numOfExprs;
int32_t bytes = pStateColInfoData->info.bytes;
@ -988,6 +989,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
if (colDataIsNull(pStateColInfoData, pBlock->info.rows, j, pAgg)) {
continue;
}
hasResult = true;
if (pStateColInfoData->pData == NULL) {
qError("%s:%d state column data is null", __FILE__, __LINE__);
pTaskInfo->code = TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR;
@ -1043,6 +1045,9 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
}
}
if (!hasResult) {
return;
}
SResultRow* pResult = NULL;
pRowSup->win.ekey = tsList[pBlock->info.rows - 1];
int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &pRowSup->win, masterScan, &pResult, gid,

View File

@ -53,7 +53,7 @@ typedef struct STranslateContext {
int32_t biRewriteToTbnameFunc(STranslateContext* pCxt, SNode** ppNode, bool* pRet);
int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect);
int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SCreateTableStmt* pStmt);
int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SNodeList* pTags, SNodeList* pCols);
int32_t findTable(STranslateContext* pCxt, const char* pTableAlias, STableNode** pOutput);
int32_t getTargetMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta,
bool couldBeView);

View File

@ -1992,10 +1992,10 @@ int32_t biRewriteToTbnameFunc(STranslateContext* pCxt, SNode** ppNode, bool* pRe
return TSDB_CODE_SUCCESS;
}
int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SCreateTableStmt* pStmt) {
if (pStmt->pTags) {
int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SNodeList* pTags, SNodeList* pCols) {
if (pTags) {
SNode* pNode = NULL;
FOREACH(pNode, pStmt->pTags) {
FOREACH(pNode, pTags) {
SColumnDefNode* pTag = (SColumnDefNode*)pNode;
if (strcasecmp(pTag->colName, "tbname") == 0) {
int32_t code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME,
@ -2004,9 +2004,9 @@ int32_t biCheckCreateTableTbnameCol(STranslateContext* pCxt, SCreateTableStmt* p
}
}
}
if (pStmt->pCols) {
if (pCols) {
SNode* pNode = NULL;
FOREACH(pNode, pStmt->pCols) {
FOREACH(pNode, pCols) {
SColumnDefNode* pCol = (SColumnDefNode*)pNode;
if (strcasecmp(pCol->colName, "tbname") == 0) {
int32_t code = generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_COLUMN,
@ -9673,7 +9673,7 @@ static int32_t translateS3MigrateDatabase(STranslateContext* pCxt, SS3MigrateDat
return buildCmdMsg(pCxt, TDMT_MND_S3MIGRATE_DB, (FSerializeFunc)tSerializeSS3MigrateDbReq, &req);
}
static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray, bool calBytes) {
static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray, bool calBytes, bool virtualTable) {
*pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SFieldWithOptions));
if (!pArray) return terrno;
@ -9681,6 +9681,10 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray, bool calB
SNode* pNode;
FOREACH(pNode, pList) {
SColumnDefNode* pCol = (SColumnDefNode*)pNode;
if (virtualTable && IS_DECIMAL_TYPE(pCol->dataType.type)) {
code = TSDB_CODE_VTABLE_NOT_SUPPORT_DATA_TYPE;
break;
}
SFieldWithOptions field = {.type = pCol->dataType.type, .bytes = calcTypeBytes(pCol->dataType)};
if (calBytes) {
field.bytes = calcTypeBytes(pCol->dataType);
@ -9715,7 +9719,7 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray, bool calB
return code;
}
static int32_t tagDefNodeToField(SNodeList* pList, SArray** pArray, bool calBytes) {
static int32_t tagDefNodeToField(SNodeList* pList, SArray** pArray, bool calBytes, bool virtualTable) {
*pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField));
if (!*pArray) return terrno;
SNode* pNode;
@ -9724,6 +9728,11 @@ static int32_t tagDefNodeToField(SNodeList* pList, SArray** pArray, bool calByte
SField field = {
.type = pCol->dataType.type,
};
if (virtualTable && IS_DECIMAL_TYPE(pCol->dataType.type)) {
taosArrayDestroy(*pArray);
*pArray = NULL;
return TSDB_CODE_VTABLE_NOT_SUPPORT_DATA_TYPE;
}
if (calBytes) {
field.bytes = calcTypeBytes(pCol->dataType);
} else {
@ -9987,6 +9996,10 @@ static int32_t checkTableSchema(STranslateContext* pCxt, SCreateTableStmt* pStmt
return checkTableSchemaImpl(pCxt, pStmt->pTags, pStmt->pCols, pStmt->pOptions->pRollupFuncs);
}
static int32_t checkVTableSchema(STranslateContext* pCxt, SCreateVTableStmt* pStmt) {
return checkTableSchemaImpl(pCxt, NULL, pStmt->pCols, NULL);
}
static int32_t getTableDelayOrWatermarkOption(STranslateContext* pCxt, const char* pName, int64_t minVal,
int64_t maxVal, SValueNode* pVal, int64_t* pMaxDelay) {
int32_t code = (DEAL_RES_ERROR == translateValue(pCxt, pVal) ? pCxt->errCode : TSDB_CODE_SUCCESS);
@ -10147,7 +10160,7 @@ static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt
}
}
if (pCxt->pParseCxt->biMode != 0 && TSDB_CODE_SUCCESS == code) {
code = biCheckCreateTableTbnameCol(pCxt, pStmt);
code = biCheckCreateTableTbnameCol(pCxt, pStmt->pTags, pStmt->pCols);
}
return code;
}
@ -10546,8 +10559,8 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm
pReq->source = TD_REQ_FROM_APP;
// columnDefNodeToField(pStmt->pCols, &pReq->pColumns, true);
// columnDefNodeToField(pStmt->pTags, &pReq->pTags, true);
code = columnDefNodeToField(pStmt->pCols, &pReq->pColumns, true);
if (TSDB_CODE_SUCCESS == code) code = tagDefNodeToField(pStmt->pTags, &pReq->pTags, true);
code = columnDefNodeToField(pStmt->pCols, &pReq->pColumns, true, pStmt->pOptions->virtualStb);
if (TSDB_CODE_SUCCESS == code) code = tagDefNodeToField(pStmt->pTags, &pReq->pTags, true, pStmt->pOptions->virtualStb);
if (TSDB_CODE_SUCCESS == code) {
pReq->numOfColumns = LIST_LENGTH(pStmt->pCols);
pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
@ -10776,6 +10789,10 @@ static SSchema* getTagSchema(const STableMeta* pTableMeta, const char* pTagName)
static int32_t checkAlterSuperTableBySchema(STranslateContext* pCxt, SAlterTableStmt* pStmt,
const STableMeta* pTableMeta) {
if (pTableMeta->virtualStb && IS_DECIMAL_TYPE(pStmt->dataType.type)) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_VTABLE_NOT_SUPPORT_DATA_TYPE);
}
SSchema* pTagsSchema = getTableTagSchema(pTableMeta);
if (getNumOfTags(pTableMeta) == 1 && pTagsSchema->type == TSDB_DATA_TYPE_JSON &&
(pStmt->alterType == TSDB_ALTER_TABLE_ADD_TAG || pStmt->alterType == TSDB_ALTER_TABLE_DROP_TAG ||
@ -13483,10 +13500,10 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt*
pReq->igUpdate = pStmt->pOptions->ignoreUpdate;
if (pReq->createStb) {
pReq->numOfTags = LIST_LENGTH(pStmt->pTags);
code = tagDefNodeToField(pStmt->pTags, &pReq->pTags, true);
code = tagDefNodeToField(pStmt->pTags, &pReq->pTags, true, false);
}
if (TSDB_CODE_SUCCESS == code) {
code = columnDefNodeToField(pStmt->pCols, &pReq->pCols, false);
code = columnDefNodeToField(pStmt->pCols, &pReq->pCols, false, false);
}
pReq->recalculateInterval = 0;
if (NULL != pStmt->pOptions->pRecInterval) {
@ -17694,6 +17711,12 @@ static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, S
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DUPLICATED_COLUMN);
}
if (TSDB_VIRTUAL_CHILD_TABLE == pTableMeta->tableType || TSDB_VIRTUAL_NORMAL_TABLE == pTableMeta->tableType) {
if (IS_DECIMAL_TYPE(pStmt->dataType.type)) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_VTABLE_NOT_SUPPORT_DATA_TYPE);
}
}
if ((TSDB_DATA_TYPE_VARCHAR == pStmt->dataType.type && calcTypeBytes(pStmt->dataType) > TSDB_MAX_BINARY_LEN) ||
(TSDB_DATA_TYPE_VARBINARY == pStmt->dataType.type && calcTypeBytes(pStmt->dataType) > TSDB_MAX_BINARY_LEN) ||
(TSDB_DATA_TYPE_NCHAR == pStmt->dataType.type && calcTypeBytes(pStmt->dataType) > TSDB_MAX_NCHAR_LEN)) {
@ -18174,15 +18197,40 @@ _return:
return code;
}
static int32_t checkCreateVirtualTable(STranslateContext* pCxt, SCreateVTableStmt* pStmt) {
if (NULL != strchr(pStmt->tableName, '.')) {
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME,
"The table name cannot contain '.'");
}
if (IS_SYS_DBNAME(pStmt->dbName)) {
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_TSC_INVALID_OPERATION,
"Cannot create table of system database: `%s`.`%s`", pStmt->dbName,
pStmt->tableName);
}
PAR_ERR_RET(checkVTableSchema(pCxt, pStmt));
PAR_ERR_RET(checkColumnOptions(pStmt->pCols));
if (pCxt->pParseCxt->biMode != 0) {
PAR_ERR_RET(biCheckCreateTableTbnameCol(pCxt, NULL, pStmt->pCols));
}
return TSDB_CODE_SUCCESS;
}
static int32_t rewriteCreateVirtualTable(STranslateContext* pCxt, SQuery* pQuery) {
SCreateVTableStmt* pStmt = (SCreateVTableStmt*)pQuery->pRoot;
int32_t code = TSDB_CODE_SUCCESS;// TODO(smj):checkCreateTable(pCxt, pStmt, false);
int32_t code = TSDB_CODE_SUCCESS;
SVgroupInfo info = {0};
SName name = {0};
SArray* pBufArray = NULL;
SNode* pNode = NULL;
int32_t index = 0;
PAR_ERR_JRET(checkCreateVirtualTable(pCxt, pStmt));
pBufArray = taosArrayInit(1, POINTER_BYTES);
if (NULL == pBufArray) {
PAR_ERR_JRET(terrno);
@ -18197,6 +18245,9 @@ static int32_t rewriteCreateVirtualTable(STranslateContext* pCxt, SQuery* pQuery
if (index == 0) {
PAR_ERR_JRET(generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_VTABLE_PRIMTS_HAS_REF));
}
if (IS_DECIMAL_TYPE(pColNode->dataType.type)) {
PAR_ERR_JRET(generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_VTABLE_NOT_SUPPORT_DATA_TYPE));
}
PAR_ERR_JRET(checkColRef(pCxt, pColOptions->refDb, pColOptions->refTable, pColOptions->refColumn,
(SDataType){.type = pColNode->dataType.type,
.bytes = calcTypeBytes(pColNode->dataType)}));
@ -18217,7 +18268,7 @@ _return:
}
static int32_t rewriteCreateVirtualSubTable(STranslateContext* pCxt, SQuery* pQuery) {
int32_t code = TSDB_CODE_SUCCESS;// TODO(smj):checkCreateTable(pCxt, pStmt, false);
int32_t code = TSDB_CODE_SUCCESS;
SCreateVSubTableStmt* pStmt = (SCreateVSubTableStmt*)pQuery->pRoot;
SVgroupInfo info = {0};
SName name = {0};

View File

@ -1018,6 +1018,7 @@ int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
if (qwMsg->msg) {
code = qwStartDynamicTaskNewExec(QW_FPARAMS(), ctx, qwMsg);
qwMsg->msg = NULL;
goto _return;
}
@ -1063,6 +1064,10 @@ _return:
QW_UNLOCK(QW_WRITE, &ctx->lock);
}
if (qwMsg->msg) {
qDestroyOperatorParam(qwMsg->msg);
}
input.code = code;
code = qwHandlePostPhaseEvents(QW_FPARAMS(), QW_PHASE_POST_FETCH, &input, NULL);

View File

@ -908,6 +908,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VTABLE_SCAN_INTERNAL_ERROR, "Virtual table scan
TAOS_DEFINE_ERROR(TSDB_CODE_VTABLE_SCAN_INVALID_DOWNSTREAM, "Virtual table scan invalid downstream operator type")
TAOS_DEFINE_ERROR(TSDB_CODE_VTABLE_PRIMTS_HAS_REF, "Virtual table prim timestamp column should not has ref column")
TAOS_DEFINE_ERROR(TSDB_CODE_VTABLE_NOT_VIRTUAL_SUPER_TABLE, "Create virtual child table must use virtual super table")
TAOS_DEFINE_ERROR(TSDB_CODE_VTABLE_NOT_SUPPORT_DATA_TYPE, "Virtual table not support decimal type")
#ifdef TAOS_ERROR_C
};
#endif

View File

@ -3018,7 +3018,7 @@ taos> select stateduration(u_tinyint_col, "GT", 20, 1a) from test_vtable_select.
taos> select twa(int_col) from test_vtable_select.vtb_virtual_stb limit 50;
twa(int_col) |
============================
-353350886.922845 |
-353350600.12852 |
taos> select abs(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
abs(int_tag) |

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,6 @@
taos> select _wstart, _wend, first(*), last(*), count(*) from test_vtable_select.vtb_virtual_stb state_window(bool_col) order by _wstart limit 100 ;
_wstart | _wend | first(ts) | first(u_tinyint_col) | first(u_smallint_col) | first(u_int_col) | first(u_bigint_col) | first(tinyint_col) | first(smallint_col) | first(int_col) | first(bigint_col) | first(float_col) | first(double_col) | first(bool_col) | first(binary_16_col) | first(binary_32_col) | first(nchar_16_col) | first(nchar_32_col) | last(ts) | last(u_tinyint_col) | last(u_smallint_col) | last(u_int_col) | last(u_bigint_col) | last(tinyint_col) | last(smallint_col) | last(int_col) | last(bigint_col) | last(float_col) | last(double_col) | last(bool_col) | last(binary_16_col) | last(binary_32_col) | last(nchar_16_col) | last(nchar_32_col) | count(*) |
==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================
1970-01-01 08:00:00.000 | 2020-10-01 00:00:49.995 | 2020-10-01 00:00:00.000 | 29 | 13238 | 432633471 | NULL | NULL | NULL | -650873068 | -9223372036854775808 | 99528.7 | NULL | NULL | NULL | Shanghai - Los Angles | 一。San Franc | 圣克拉拉 - Santa Clara | 2020-10-01 00:00:45.975 | 183 | 26437 | 1670071451 | NULL | NULL | NULL | -785713543 | -9223372036854775808 | 24230.5 | NULL | NULL | NULL | Taiyuan - Santa Clara | 四。San Jose | 帕洛阿托 - Palo Alto | 0 |
2020-10-01 00:00:00.000 | 2020-10-01 00:00:00.000 | 2020-10-01 00:00:00.000 | 29 | 13238 | 432633471 | 1825145387 | 80 | 32519 | -650873068 | -9223372036854775808 | 99528.7 | 73495720.958304 | true | San Diego | Shanghai - Los Angles | 一。San Franc | 圣克拉拉 - Santa Clara | 2020-10-01 00:00:00.000 | 29 | 13238 | 432633471 | 1825145387 | 80 | 32519 | -650873068 | -9223372036854775808 | 99528.7 | 73495720.958304 | true | San Diego | Shanghai - Los Angles | 一。San Franc | 圣克拉拉 - Santa Clara | 1 |
2020-10-01 00:00:00.003 | 2020-10-01 00:00:00.003 | 2020-10-01 00:00:00.003 | NULL | 30154 | NULL | NULL | 44 | NULL | NULL | -9223372036854775808 | NULL | NULL | false | NULL | NULL | 三。San Diego | NULL | 2020-10-01 00:00:00.003 | NULL | 30154 | NULL | NULL | 44 | NULL | NULL | -9223372036854775808 | NULL | NULL | false | NULL | NULL | 三。San Diego | NULL | 2 |
2020-10-01 00:00:00.006 | 2020-10-01 00:00:00.009 | 2020-10-01 00:00:00.006 | 49 | 51523 | NULL | 654411 | -91 | NULL | -140653792 | -9223372036854775808 | NULL | 4540042.841226 | true | NULL | Shanghai - Los Angles | 六。Campbell | NULL | 2020-10-01 00:00:00.008 | 74 | 51523 | NULL | 1158746468 | -91 | NULL | -439167365 | -9223372036854775808 | NULL | -16761361.20062 | true | NULL | Shanghai - Los Angles | 六。Campbell | NULL | 4 |
@ -102,6 +101,7 @@ taos> select _wstart, _wend, first(*), last(*), count(*) from test_vtable_select
2020-10-01 00:00:00.639 | 2020-10-01 00:00:00.642 | 2020-10-01 00:00:00.639 | 71 | 23769 | 1047447204 | 902724244 | 79 | -15245 | -556439232 | -9223372036854775808 | -14500.9 | 2431931.650446 | true | Palo Alto | Tianjin - Mountain View | 一。San Franc | 圣克拉拉 - Santa Clara | 2020-10-01 00:00:00.640 | 71 | 23769 | 1047447204 | 902724244 | 79 | -15245 | -556439232 | -9223372036854775808 | -14500.9 | 2431931.650446 | true | Palo Alto | Tianjin - Mountain View | 一。San Franc | 圣克拉拉 - Santa Clara | 4 |
2020-10-01 00:00:00.645 | 2020-10-01 00:00:00.645 | 2020-10-01 00:00:00.645 | NULL | 50372 | 1756705093 | NULL | 4 | 11012 | NULL | -9223372036854775808 | -28602.3 | NULL | false | Mountain View | NULL | 二。Los Angle | 圣地亚哥 - San Diego | 2020-10-01 00:00:00.645 | NULL | 50372 | 1756705093 | NULL | 4 | 11012 | NULL | -9223372036854775808 | -28602.3 | NULL | false | Mountain View | NULL | 二。Los Angle | 圣地亚哥 - San Diego | 2 |
2020-10-01 00:00:00.648 | 2020-10-01 00:00:00.648 | 2020-10-01 00:00:00.648 | 36 | 40209 | NULL | 2011281951 | 87 | NULL | 237103738 | -9223372036854775808 | NULL | -60794244.376766 | true | NULL | Taiyuan - Santa Clara | 一。San Franc | NULL | 2020-10-01 00:00:00.648 | 36 | 40209 | NULL | 2011281951 | 87 | NULL | 237103738 | -9223372036854775808 | NULL | -60794244.376766 | true | NULL | Taiyuan - Santa Clara | 一。San Franc | NULL | 2 |
2020-10-01 00:00:00.651 | 2020-10-01 00:00:00.651 | 2020-10-01 00:00:00.651 | NULL | 24193 | NULL | NULL | -86 | NULL | NULL | -9223372036854775808 | NULL | NULL | false | NULL | NULL | 七。Mountain | NULL | 2020-10-01 00:00:00.651 | NULL | 24193 | NULL | NULL | -86 | NULL | NULL | -9223372036854775808 | NULL | NULL | false | NULL | NULL | 七。Mountain | NULL | 2 |
taos> select _wstart, _wend, first(bool_col), last(bool_col), count(bool_col) from test_vtable_select.vtb_virtual_stb state_window(bool_col) order by _wstart limit 100 ;
_wstart | _wend | first(bool_col) | last(bool_col) | count(bool_col) |
@ -210,7 +210,6 @@ taos> select _wstart, _wend, first(bool_col), last(bool_col), count(bool_col) fr
taos> select _wstart, _wend, first(bool_col), first(u_tinyint_col), last(bool_col), last(u_tinyint_col), count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb state_window(bool_col) order by _wstart limit 100;
_wstart | _wend | first(bool_col) | first(u_tinyint_col) | last(bool_col) | last(u_tinyint_col) | count(u_tinyint_col) |
============================================================================================================================================================
1970-01-01 08:00:00.000 | 2020-10-01 00:00:19.998 | NULL | 29 | NULL | 137 | 0 |
2020-10-01 00:00:00.000 | 2020-10-01 00:00:00.000 | true | 29 | true | 29 | 1 |
2020-10-01 00:00:00.003 | 2020-10-01 00:00:00.003 | false | NULL | false | NULL | 0 |
2020-10-01 00:00:00.006 | 2020-10-01 00:00:00.009 | true | 49 | true | 74 | 4 |
@ -310,11 +309,11 @@ taos> select _wstart, _wend, first(bool_col), first(u_tinyint_col), last(bool_co
2020-10-01 00:00:00.639 | 2020-10-01 00:00:00.642 | true | 71 | true | 71 | 2 |
2020-10-01 00:00:00.645 | 2020-10-01 00:00:00.645 | false | NULL | false | NULL | 0 |
2020-10-01 00:00:00.648 | 2020-10-01 00:00:00.648 | true | 36 | true | 36 | 2 |
2020-10-01 00:00:00.651 | 2020-10-01 00:00:00.651 | false | NULL | false | NULL | 0 |
taos> select _wstart, _wend, first(bool_col), first(u_tinyint_col), first(u_smallint_col), last(bool_col), last(u_tinyint_col), last(u_smallint_col), count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb state_window(bool_col) order by _wstart limit 100 ;
_wstart | _wend | first(bool_col) | first(u_tinyint_col) | first(u_smallint_col) | last(bool_col) | last(u_tinyint_col) | last(u_smallint_col) | count(u_tinyint_col) |
===========================================================================================================================================================================================================
1970-01-01 08:00:00.000 | 2020-10-01 00:00:29.997 | NULL | 29 | 13238 | NULL | 72 | 28494 | 0 |
2020-10-01 00:00:00.000 | 2020-10-01 00:00:00.000 | true | 29 | 13238 | true | 29 | 13238 | 1 |
2020-10-01 00:00:00.003 | 2020-10-01 00:00:00.003 | false | NULL | 30154 | false | NULL | 30154 | 0 |
2020-10-01 00:00:00.006 | 2020-10-01 00:00:00.009 | true | 49 | 51523 | true | 74 | 51523 | 4 |
@ -414,4 +413,5 @@ taos> select _wstart, _wend, first(bool_col), first(u_tinyint_col), first(u_smal
2020-10-01 00:00:00.639 | 2020-10-01 00:00:00.642 | true | 71 | 23769 | true | 71 | 23769 | 2 |
2020-10-01 00:00:00.645 | 2020-10-01 00:00:00.645 | false | NULL | 50372 | false | NULL | 50372 | 0 |
2020-10-01 00:00:00.648 | 2020-10-01 00:00:00.648 | true | 36 | 40209 | true | 36 | 40209 | 2 |
2020-10-01 00:00:00.651 | 2020-10-01 00:00:00.651 | false | NULL | 24193 | false | NULL | 24193 | 0 |

View File

@ -129,7 +129,6 @@ select avg(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select count(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select count(*) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select elapsed(ts) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select leastsquares(int_tag, 0, 1) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select spread(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select stddev(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select sum(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
@ -150,11 +149,8 @@ select min(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select mode(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select tail(int_tag, 20) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select unique(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select csum(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select derivative(int_tag, 5a, 1) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select diff(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select irate(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select mavg(int_tag, 100) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select statecount(int_tag, "GT", 20) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select stateduration(int_tag, "GT", 20, 1a) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;
select twa(int_tag) from test_vtable_select.vtb_virtual_stb order by 1 limit 5;

View File

@ -1,83 +1,83 @@
select count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col slimit 10 limit 10;
select u_tinyint_col from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col slimit 10 limit 10;
select u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col slimit 10 limit 10;
select avg(u_int_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col slimit 10 limit 10;
select avg(u_tinyint_col), avg(u_smallint_col), avg(u_int_col), avg(u_bigint_col), avg(tinyint_col), avg(smallint_col), avg(int_col), avg(bigint_col), avg(float_col), avg(double_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col slimit 10 limit 10;
select * from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col slimit 10 limit 10;
select count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col order by 1 slimit 10 limit 10;
select u_tinyint_col from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col order by 1 slimit 10 limit 10;
select u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col order by 1 slimit 10 limit 10;
select avg(u_int_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col order by 1 slimit 10 limit 10;
select avg(u_tinyint_col), avg(u_smallint_col), avg(u_int_col), avg(u_bigint_col), avg(tinyint_col), avg(smallint_col), avg(int_col), avg(bigint_col), avg(float_col), avg(double_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col order by 1 slimit 10 limit 10;
select * from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col order by 1, 2, int_tag slimit 10 limit 10;
select count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 slimit 10 limit 10;
select u_tinyint_col + 1 from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 slimit 10 limit 10;
select u_tinyint_col + 1, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 slimit 10 limit 10;
select avg(u_int_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 slimit 10 limit 10;
select avg(u_tinyint_col), avg(u_smallint_col), avg(u_int_col), avg(u_bigint_col), avg(tinyint_col), avg(smallint_col), avg(int_col), avg(bigint_col), avg(float_col), avg(double_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 slimit 10 limit 10;
select * from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 slimit 10 limit 10;
select count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 order by 1 slimit 10 limit 10;
select u_tinyint_col + 1 from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 order by 1 slimit 10 limit 10;
select u_tinyint_col + 1, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 order by 1 slimit 10 limit 10;
select avg(u_int_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 order by 1 slimit 10 limit 10;
select avg(u_tinyint_col), avg(u_smallint_col), avg(u_int_col), avg(u_bigint_col), avg(tinyint_col), avg(smallint_col), avg(int_col), avg(bigint_col), avg(float_col), avg(double_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 order by 1 slimit 10 limit 10;
select * from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col + 1 order by 1, 2, int_tag slimit 10 limit 10;
select count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col slimit 10 limit 10;
select u_tinyint_col, tinyint_col from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col slimit 10 limit 10;
select u_tinyint_col, tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col slimit 10 limit 10;
select avg(u_int_col), avg(tinyint_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col slimit 10 limit 10;
select avg(u_tinyint_col), avg(u_smallint_col), avg(u_int_col), avg(u_bigint_col), avg(tinyint_col), avg(smallint_col), avg(int_col), avg(bigint_col), avg(float_col), avg(double_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col slimit 10 limit 10;
select * from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col slimit 10 limit 10;
select count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col order by 1 slimit 10 limit 10;
select u_tinyint_col, tinyint_col from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col order by 1 slimit 10 limit 10;
select u_tinyint_col, tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col order by 1 slimit 10 limit 10;
select avg(u_int_col), avg(tinyint_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col order by 1 slimit 10 limit 10;
select avg(u_tinyint_col), avg(u_smallint_col), avg(u_int_col), avg(u_bigint_col), avg(tinyint_col), avg(smallint_col), avg(int_col), avg(bigint_col), avg(float_col), avg(double_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col order by 1 slimit 10 limit 10;
select * from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col, tinyint_col order by 1, 2, int_tag slimit 10 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(10s) slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by tinyint_col interval(10s) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col interval(10s) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col interval(1d) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by bool_col interval(1d) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by bool_col interval(1d) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by bool_col interval(1d) slimit 10 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(10s) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by tinyint_col interval(10s) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col interval(10s) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col interval(1d) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by bool_col interval(1d) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by bool_col interval(1d) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by bool_col interval(1d) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col state_window(bool_col) slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by tinyint_col state_window(bool_col) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col state_window(bool_col) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col state_window(bool_col) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col state_window(bool_col) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col state_window(bool_col) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col state_window(bool_col) slimit 10 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col state_window(bool_col) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by tinyint_col state_window(bool_col) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col state_window(bool_col) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col state_window(bool_col) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col state_window(bool_col) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col state_window(bool_col) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col state_window(bool_col) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col session(ts, 10a) slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by tinyint_col session(ts, 10a) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col session(ts, 10a) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col session(ts, 10a) slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col session(ts, 10a) slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col session(ts, 10a) slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col session(ts, 10a) slimit 10 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col session(ts, 10a) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by tinyint_col session(ts, 10a) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col session(ts, 10a) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col session(ts, 10a) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col session(ts, 10a) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col session(ts, 10a) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by tinyint_col session(ts, 10a) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(tinyint_col), u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with tinyint_col > 100 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(tinyint_col), u_tinyint_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with tinyint_col > 100 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(tinyint_col), u_tinyint_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with tinyint_col > 100 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(tinyint_col), u_tinyint_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with tinyint_col > 100 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(tinyint_col), u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with tinyint_col > 100 order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(tinyint_col), u_tinyint_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with tinyint_col > 100 order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(tinyint_col), u_tinyint_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with tinyint_col > 100 order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(tinyint_col), u_tinyint_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with tinyint_col > 100 order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(smallint_col), u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with smallint_col > 1000 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(smallint_col), u_tinyint_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with smallint_col > 1000 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(smallint_col), u_tinyint_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with smallint_col > 1000 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(smallint_col), u_tinyint_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with smallint_col > 1000 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(smallint_col), u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with smallint_col > 1000 order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(smallint_col), u_tinyint_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with smallint_col > 1000 order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(smallint_col), u_tinyint_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with smallint_col > 1000 order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, first(tinyint_col), last(smallint_col), u_tinyint_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col event_window start with tinyint_col > 50 end with smallint_col > 1000 order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col count_window(10) slimit 10 limit 10;
select _wstart, _wend, tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by tinyint_col count_window(10) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col count_window(10) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*) from test_vtable_select.vtb_virtual_stb partition by bool_col count_window(10) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from test_vtable_select.vtb_virtual_stb partition by bool_col count_window(10) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col),count(u_tinyint_col) from test_vtable_select.vtb_virtual_stb partition by bool_col count_window(10) slimit 10 limit 10;
select _wstart, _wend, bool_col, count(*), count(u_int_col) from test_vtable_select.vtb_virtual_stb partition by bool_col count_window(10) slimit 10 limit 10;
select _wstart, _wend, count(*) from (select * from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col order by 1) count_window(10) order by 1,2,3 limit 10;
select _wstart, _wend, count(*) from (select * from test_vtable_select.vtb_virtual_stb partition by tinyint_col order by 1) count_window(10) order by 1,2,3 limit 10;
select _wstart, _wend, count(*) from (select * from test_vtable_select.vtb_virtual_stb partition by bool_col order by 1) count_window(10) order by 1,2,3 limit 10;
select _wstart, _wend, count(*) from (select * from test_vtable_select.vtb_virtual_stb partition by bool_col order by 1) count_window(10) order by 1,2,3 limit 10;
select _wstart, _wend, count(*), count(u_int_col),count(u_tinyint_col), count(u_smallint_col) from (select * from test_vtable_select.vtb_virtual_stb partition by bool_col order by 1) count_window(10) order by 1,2,3,4 limit 10;
select _wstart, _wend, count(*), count(u_int_col),count(u_tinyint_col) from (select * from test_vtable_select.vtb_virtual_stb partition by bool_col order by 1) count_window(10) order by 1,2,3,4 limit 10;
select _wstart, _wend, count(*), count(u_int_col) from (select * from test_vtable_select.vtb_virtual_stb partition by bool_col order by 1) count_window(10) order by 1,2,3,4 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) slimit 10 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) slimit 2 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) slimit 2 limit 5;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) slimit 20 limit 2;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) slimit 20 limit 5;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) slimit 10 limit 2;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) order by 1,2,3,4 slimit 10 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) order by 1,2,3,4 slimit 2 limit 10;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) order by 1,2,3,4 slimit 2 limit 5;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) order by 1,2,3,4 slimit 20 limit 2;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) order by 1,2,3,4 slimit 20 limit 5;
select _wstart, _wend, u_tinyint_col, count(*) from test_vtable_select.vtb_virtual_stb partition by u_tinyint_col interval(1s) order by 1,2,3,4 slimit 10 limit 2;
select count(*) from test_vtable_select.vtb_virtual_stb partition by int_tag slimit 10 limit 10;
select int_tag from test_vtable_select.vtb_virtual_stb partition by int_tag slimit 10 limit 10;
select int_tag, count(*) from test_vtable_select.vtb_virtual_stb partition by int_tag slimit 10 limit 10;
select avg(u_int_col) from test_vtable_select.vtb_virtual_stb partition by int_tag slimit 10 limit 10;
select avg(u_tinyint_col), avg(u_smallint_col), avg(u_int_col), avg(u_bigint_col), avg(tinyint_col), avg(smallint_col), avg(int_col), avg(bigint_col), avg(float_col), avg(double_col) from test_vtable_select.vtb_virtual_stb partition by int_tag slimit 10 limit 10;
select * from test_vtable_select.vtb_virtual_stb partition by int_tag slimit 10 limit 10;
select count(*) from test_vtable_select.vtb_virtual_stb partition by int_tag order by 1 slimit 10 limit 10;
select int_tag from test_vtable_select.vtb_virtual_stb partition by int_tag order by 1 slimit 10 limit 10;
select int_tag, count(*) from test_vtable_select.vtb_virtual_stb partition by int_tag order by 1 slimit 10 limit 10;
select avg(u_int_col) from test_vtable_select.vtb_virtual_stb partition by int_tag order by 1 slimit 10 limit 10;
select avg(u_tinyint_col), avg(u_smallint_col), avg(u_int_col), avg(u_bigint_col), avg(tinyint_col), avg(smallint_col), avg(int_col), avg(bigint_col), avg(float_col), avg(double_col) from test_vtable_select.vtb_virtual_stb partition by int_tag order by 1 slimit 10 limit 10;
select * from test_vtable_select.vtb_virtual_stb partition by int_tag order by 1, 2, int_tag slimit 10 limit 10;
select count(*) from test_vtable_select.vtb_virtual_stb partition by tbname slimit 10 limit 10;
select tbname from test_vtable_select.vtb_virtual_stb partition by tbname slimit 10 limit 10;
select tbname, count(*) from test_vtable_select.vtb_virtual_stb partition by tbname slimit 10 limit 10;
select avg(u_int_col) from test_vtable_select.vtb_virtual_stb partition by tbname slimit 10 limit 10;
select avg(u_tinyint_col), avg(u_smallint_col), avg(u_int_col), avg(u_bigint_col), avg(tinyint_col), avg(smallint_col), avg(int_col), avg(bigint_col), avg(float_col), avg(double_col) from test_vtable_select.vtb_virtual_stb partition by tbname slimit 10 limit 10;
select * from test_vtable_select.vtb_virtual_stb partition by tbname slimit 10 limit 10;
select count(*) from test_vtable_select.vtb_virtual_stb partition by tbname order by 1 slimit 10 limit 10;
select tbname from test_vtable_select.vtb_virtual_stb partition by tbname order by 1 slimit 10 limit 10;
select tbname, count(*) from test_vtable_select.vtb_virtual_stb partition by tbname order by 1 slimit 10 limit 10;
select avg(u_int_col) from test_vtable_select.vtb_virtual_stb partition by tbname order by 1 slimit 10 limit 10;
select avg(u_tinyint_col), avg(u_smallint_col), avg(u_int_col), avg(u_bigint_col), avg(tinyint_col), avg(smallint_col), avg(int_col), avg(bigint_col), avg(float_col), avg(double_col) from test_vtable_select.vtb_virtual_stb partition by tbname order by 1 slimit 10 limit 10;
select * from test_vtable_select.vtb_virtual_stb partition by tbname order by 1, 2, int_tag slimit 10 limit 10;

View File

@ -328,6 +328,9 @@ class TDTestCase(TBase):
# 1.6. change column length when column reference exists
tdSql.error("alter vtable vtb_virtual_ntb0 modify column nchar_16_col nchar(32);")
# 1.7. add column with decimal type
tdSql.error("alter vtable vtb_virtual_ntb0 add column extra_decimal decimal(38,38)")
# 2. child table
# 2.1. change column reference with wrong type
tdSql.error("alter vtable vtb_virtual_ctb0 alter column int_col set vtb_org_child_19.tinyint_col")
@ -343,6 +346,12 @@ class TDTestCase(TBase):
tdSql.execute("alter stable vtb_virtual_stb modify column nchar_16_col nchar(32);")
tdSql.error("select nchar_16_col from vtb_virtual_ctb0;")
# 3.3. add column with decimal type
tdSql.error("alter stable vtb_virtual_stb add column extra_decimal decimal(38,38)")
# 3.4. add tag with decimal type
tdSql.error("alter stable vtb_virtual_stb add tag extra_decimal_tag decimal(38,38)")
def run(self):
tdLog.debug(f"start to excute {__file__}")

View File

@ -58,9 +58,9 @@ class TDTestCase(TBase):
if (priv_orgtb != "none"):
tdSql.execute(f"grant {priv_orgtb} on test_vctable_auth_alter.test_vtable_auth_org_table_2 to test_vct_user_alter;")
sleep(1)
sleep(2)
tdLog.info(f"priv_db: {priv_db}, priv_tb1: {priv_vtb}, priv_tb2: {priv_orgtb}")
tdLog.info(f"priv_db: {priv_db}, priv_stb: {priv_vtb}, priv_ctb: {priv_orgtb}")
testSql.execute("use test_vctable_auth_alter;")
if (priv_db == "read"):
if (priv_vtb == "write" or priv_vtb == "all"):

View File

@ -702,6 +702,77 @@ class TDTestCase(TBase):
"geo_32_col FROM vtb_org_child_18.geo_32_col)"
"USING vtb_virtual_stb TAGS (13, false, 13, 13, 'vchild13', 'vchild13')")
# 11. create virtual table using decimal
# 11.1 super table
# 11.1.1 decimal column
tdSql.error(f"CREATE STABLE `vtb_virtual_stb_error` ("
"ts timestamp, "
"u_tinyint_col tinyint unsigned, "
"u_smallint_col smallint unsigned, "
"u_int_col int unsigned, "
"u_bigint_col bigint unsigned, "
"tinyint_col tinyint, "
"smallint_col smallint, "
"int_col int, "
"bigint_col bigint, "
"float_col float, "
"double_col double, "
"bool_col bool, "
"binary_16_col binary(16),"
"binary_32_col binary(32),"
"nchar_16_col nchar(16),"
"nchar_32_col nchar(32),"
"varbinary_16_col varbinary(16),"
"varbinary_32_col varbinary(32),"
"geo_16_col geometry(16),"
"geo_32_col geometry(32),"
"decimal_col decimal(38,38)"
") TAGS ("
"int_tag int,"
"bool_tag bool,"
"float_tag float,"
"double_tag double,"
"nchar_32_tag nchar(32),"
"binary_32_tag binary(32))"
"VIRTUAL 1")
# 11.1.2 decimal tag
tdSql.error(f"CREATE STABLE `vtb_virtual_stb_error` ("
"ts timestamp, "
"u_tinyint_col tinyint unsigned, "
"u_smallint_col smallint unsigned, "
"u_int_col int unsigned, "
"u_bigint_col bigint unsigned, "
"tinyint_col tinyint, "
"smallint_col smallint, "
"int_col int, "
"bigint_col bigint, "
"float_col float, "
"double_col double, "
"bool_col bool, "
"binary_16_col binary(16),"
"binary_32_col binary(32),"
"nchar_16_col nchar(16),"
"nchar_32_col nchar(32),"
"varbinary_16_col varbinary(16),"
"varbinary_32_col varbinary(32),"
"geo_16_col geometry(16),"
"geo_32_col geometry(32)"
") TAGS ("
"int_tag int,"
"bool_tag bool,"
"float_tag float,"
"double_tag double,"
"nchar_32_tag nchar(32),"
"binary_32_tag binary(32)),"
"decimal_tag decimal(38,38)"
"VIRTUAL 1")
# 11.2 virtual normal table
tdSql.error("CREATE VTABLE `error_vtb_virtual_ntb8` ("
"ts timestamp FROM vtb_org_normal_0.ts, "
"u_tinyint_col tinyint unsigned from vtb_org_normal_0.u_tinyint_col, "
"u_smallint_col smallint unsigned from vtb_org_normal_1.u_smallint_col, "
"decimal_col decimal(38,38))")
def run(self):
tdLog.debug(f"start to excute {__file__}")

View File

@ -257,12 +257,12 @@ class TDTestCase(TBase):
#self.test_normal_query("test_vstable_select_test_function")
self.test_normal_query("test_vstable_select_test_interval")
#self.test_normal_query("test_vstable_select_test_state")
self.test_normal_query("test_vstable_select_test_state")
self.test_normal_query("test_vstable_select_test_session")
#self.test_normal_query("test_vstable_select_test_event")
self.test_normal_query("test_vstable_select_test_event")
self.test_normal_query("test_vstable_select_test_count")
#self.test_normal_query("test_vstable_select_test_partition")
self.test_normal_query("test_vstable_select_test_partition")
self.test_normal_query("test_vstable_select_test_group")
self.test_normal_query("test_vstable_select_test_orderby")