scalar constant
This commit is contained in:
parent
ab459546ba
commit
65a7d0f1c2
|
@ -195,6 +195,8 @@ typedef enum EOperatorType {
|
|||
OP_TYPE_JSON_CONTAINS
|
||||
} EOperatorType;
|
||||
|
||||
#define OP_TYPE_CALC_MAX OP_TYPE_BIT_OR
|
||||
|
||||
typedef enum ELogicConditionType {
|
||||
LOGIC_COND_TYPE_AND = 1,
|
||||
LOGIC_COND_TYPE_OR,
|
||||
|
|
|
@ -11,7 +11,7 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
|||
case STMT_PREPARE:
|
||||
break;
|
||||
case STMT_SETTBNAME:
|
||||
if (STMT_STATUS_NE(PREPARE) && STMT_STATUS_NE(ADD_BATCH) && STMT_STATUS_NE(EXECUTE)) {
|
||||
if (STMT_STATUS_EQ(INIT) || STMT_STATUS_EQ(BIND) || STMT_STATUS_EQ(BIND_COL)) {
|
||||
code = TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
}
|
||||
break;
|
||||
|
@ -44,6 +44,7 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) {
|
|||
if (STMT_STATUS_NE(ADD_BATCH) && STMT_STATUS_NE(FETCH_FIELDS)) {
|
||||
code = TSDB_CODE_TSC_STMT_API_ERROR;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
code = TSDB_CODE_TSC_APP_ERROR;
|
||||
break;
|
||||
|
|
|
@ -245,6 +245,9 @@ int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo,
|
|||
|
||||
relocateColumnData(pBlock, pTableScanInfo->pColMatchInfo, pCols);
|
||||
|
||||
// reset the block to be 0 by default, this blockId is assigned by physical plan and is used by direct upstream operator.
|
||||
pBlock->info.blockId = 0;
|
||||
|
||||
doFilter(pTableScanInfo->pFilterNode, pBlock);
|
||||
if (pBlock->info.rows == 0) {
|
||||
pCost->filterOutBlocks += 1;
|
||||
|
@ -294,8 +297,6 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
|
|||
continue;
|
||||
}
|
||||
|
||||
// reset the block to be 0 by default, this blockId is assigned by physical plan and is used by direct upstream operator.
|
||||
pBlock->info.blockId = 0;
|
||||
return pBlock;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef struct SScalarCtx {
|
|||
|
||||
#define SCL_IS_CONST_NODE(_node) ((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type))
|
||||
#define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList)
|
||||
#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type))
|
||||
|
||||
#define sclFatal(...) qFatal(__VA_ARGS__)
|
||||
#define sclError(...) qError(__VA_ARGS__)
|
||||
|
|
|
@ -1031,18 +1031,29 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) {
|
|||
|
||||
SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))};
|
||||
out.columnData->info.type = type;
|
||||
out.columnData->info.bytes = tDataTypes[type].bytes;
|
||||
|
||||
for (int32_t i = 0; i < listNode->pNodeList->length; ++i) {
|
||||
SValueNode *valueNode = (SValueNode *)cell->pNode;
|
||||
code = doConvertDataType(valueNode, &out);
|
||||
if (code) {
|
||||
// fltError("convert from %d to %d failed", in.type, out.type);
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
|
||||
len = tDataTypes[type].bytes;
|
||||
if (valueNode->node.resType.type != type) {
|
||||
code = doConvertDataType(valueNode, &out);
|
||||
if (code) {
|
||||
// fltError("convert from %d to %d failed", in.type, out.type);
|
||||
FLT_ERR_RET(code);
|
||||
}
|
||||
|
||||
len = tDataTypes[type].bytes;
|
||||
|
||||
filterAddField(info, NULL, (void**) &out.columnData->pData, FLD_TYPE_VALUE, &right, len, true);
|
||||
filterAddField(info, NULL, (void**) &out.columnData->pData, FLD_TYPE_VALUE, &right, len, true);
|
||||
out.columnData->pData = NULL;
|
||||
} else {
|
||||
void *data = taosMemoryCalloc(1, tDataTypes[type].bytes);
|
||||
if (NULL == data) {
|
||||
FLT_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||
}
|
||||
memcpy(data, nodesGetValueFromNode(valueNode), tDataTypes[type].bytes);
|
||||
filterAddField(info, NULL, (void**) &data, FLD_TYPE_VALUE, &right, len, true);
|
||||
}
|
||||
filterAddUnit(info, OP_TYPE_EQUAL, &left, &right, &uidx);
|
||||
|
||||
SFilterGroup fgroup = {0};
|
||||
|
@ -3599,7 +3610,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
if ((QUERY_NODE_COLUMN != nodeType(node->pRight)) && (QUERY_NODE_VALUE != nodeType(node->pRight))) {
|
||||
if ((QUERY_NODE_COLUMN != nodeType(node->pRight)) && (QUERY_NODE_VALUE != nodeType(node->pRight)) && (QUERY_NODE_NODE_LIST != nodeType(node->pRight))) {
|
||||
stat->scalarMode = true;
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
|
|||
|
||||
for (int32_t i = 0; i < nodeList->pNodeList->length; ++i) {
|
||||
SValueNode *valueNode = (SValueNode *)cell->pNode;
|
||||
|
||||
|
||||
if (valueNode->node.resType.type != type) {
|
||||
out.columnData->info.type = type;
|
||||
out.columnData->info.bytes = tDataTypes[type].bytes;
|
||||
|
@ -176,7 +176,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
|
|||
SCL_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||
}
|
||||
|
||||
SCL_ERR_RET(scalarGenerateSetFromList((void**) ¶m->pHashFilter, node, nodeList->dataType.type));
|
||||
SCL_ERR_RET(scalarGenerateSetFromList((void **)¶m->pHashFilter, node, nodeList->dataType.type));
|
||||
if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) {
|
||||
taosHashCleanup(param->pHashFilter);
|
||||
sclError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param));
|
||||
|
@ -483,6 +483,79 @@ _return:
|
|||
SCL_RET(code);
|
||||
}
|
||||
|
||||
EDealRes sclRewriteBasedOnOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opType) {
|
||||
if (opType <= OP_TYPE_CALC_MAX) {
|
||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
res->node.resType.type = TSDB_DATA_TYPE_NULL;
|
||||
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)res;
|
||||
} else {
|
||||
SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE);
|
||||
if (NULL == res) {
|
||||
sclError("make value node failed");
|
||||
ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return DEAL_RES_ERROR;
|
||||
}
|
||||
|
||||
res->node.resType.type = TSDB_DATA_TYPE_BOOL;
|
||||
res->datum.b = false;
|
||||
|
||||
nodesDestroyNode(*pNode);
|
||||
*pNode = (SNode*)res;
|
||||
}
|
||||
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
EDealRes sclRewriteOperatorForNullValue(SNode** pNode, SScalarCtx *ctx) {
|
||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||
|
||||
if (node->pLeft && (QUERY_NODE_VALUE == nodeType(node->pLeft))) {
|
||||
SValueNode *valueNode = (SValueNode *)node->pLeft;
|
||||
if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)) {
|
||||
return sclRewriteBasedOnOptr(pNode, ctx, node->opType);
|
||||
}
|
||||
}
|
||||
|
||||
if (node->pRight && (QUERY_NODE_VALUE == nodeType(node->pRight))) {
|
||||
SValueNode *valueNode = (SValueNode *)node->pRight;
|
||||
if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)) {
|
||||
return sclRewriteBasedOnOptr(pNode, ctx, node->opType);
|
||||
}
|
||||
}
|
||||
|
||||
if (node->pRight && (QUERY_NODE_NODE_LIST == nodeType(node->pRight))) {
|
||||
SNodeListNode *listNode = (SNodeListNode *)node->pRight;
|
||||
SNode* tnode = NULL;
|
||||
WHERE_EACH(tnode, listNode->pNodeList) {
|
||||
if (SCL_IS_NULL_VALUE_NODE(tnode)) {
|
||||
if (node->opType == OP_TYPE_IN) {
|
||||
ERASE_NODE(listNode->pNodeList);
|
||||
continue;
|
||||
} else { //OP_TYPE_NOT_IN
|
||||
return sclRewriteBasedOnOptr(pNode, ctx, node->opType);
|
||||
}
|
||||
}
|
||||
|
||||
WHERE_NEXT;
|
||||
}
|
||||
|
||||
if (listNode->pNodeList->length <= 0) {
|
||||
return sclRewriteBasedOnOptr(pNode, ctx, node->opType);
|
||||
}
|
||||
}
|
||||
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) {
|
||||
SFunctionNode *node = (SFunctionNode *)*pNode;
|
||||
SNode* tnode = NULL;
|
||||
|
@ -572,12 +645,8 @@ EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) {
|
|||
EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
|
||||
SOperatorNode *node = (SOperatorNode *)*pNode;
|
||||
|
||||
if (!SCL_IS_CONST_NODE(node->pLeft)) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
if (!SCL_IS_CONST_NODE(node->pRight)) {
|
||||
return DEAL_RES_CONTINUE;
|
||||
if ((!SCL_IS_CONST_NODE(node->pLeft)) || (!SCL_IS_CONST_NODE(node->pRight))) {
|
||||
return sclRewriteOperatorForNullValue(pNode, ctx);
|
||||
}
|
||||
|
||||
SScalarParam output = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))};
|
||||
|
|
|
@ -1367,7 +1367,8 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
|||
if (pRight->pHashFilter != NULL) {
|
||||
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i)) {
|
||||
colDataAppendNULL(pOut->columnData, i);
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1381,7 +1382,8 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
|||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i)) {
|
||||
colDataAppendNULL(pOut->columnData, i);
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
|
||||
|
@ -1402,8 +1404,9 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
|||
} else if (pRight->numOfRows == 1) {
|
||||
ASSERT(pLeft->pHashFilter == NULL);
|
||||
for (; i >= 0 && i < pLeft->numOfRows; i += step) {
|
||||
if (colDataIsNull_s(pLeft->columnData, i)) {
|
||||
colDataAppendNULL(pOut->columnData, i);
|
||||
if (colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, 0)) {
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1422,8 +1425,9 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
|
|||
}
|
||||
} else if (pLeft->numOfRows == 1) {
|
||||
for (; i >= 0 && i < pRight->numOfRows; i += step) {
|
||||
if (colDataIsNull_s(pRight->columnData, i)) {
|
||||
colDataAppendNULL(pOut->columnData, i);
|
||||
if (colDataIsNull_s(pRight->columnData, i) || colDataIsNull_s(pLeft->columnData, 0)) {
|
||||
bool res = false;
|
||||
colDataAppendInt8(pOut->columnData, i, (int8_t*)&res);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,15 +97,14 @@ CaseCfg gCase[] = {
|
|||
{"insert:MBME4-C012", tListLen(fullColList), fullColList, false, false, insertMBMETest4, 10, 10, 2, 12, 0, 1},
|
||||
{"insert:MBME4-C002", tListLen(fullColList), fullColList, false, false, insertMBMETest4, 10, 10, 2, 2, 0, 1},
|
||||
|
||||
|
||||
{"insert:MPME1-FULL", tListLen(fullColList), fullColList, false, true, insertMPMETest1, 10, 10, 2, 0, 0, 1},
|
||||
{"insert:MPME1-C012", tListLen(fullColList), fullColList, false, false, insertMPMETest1, 10, 10, 2, 12, 0, 1},
|
||||
|
||||
};
|
||||
|
||||
CaseCfg *gCurCase = NULL;
|
||||
|
||||
typedef struct {
|
||||
char caseCatalog[255];
|
||||
int32_t bindNullNum;
|
||||
bool autoCreate;
|
||||
bool checkParamNum;
|
||||
|
@ -118,6 +117,8 @@ typedef struct {
|
|||
int32_t bindColTypeNum;
|
||||
int32_t* bindColTypeList;
|
||||
int32_t runTimes;
|
||||
int32_t caseIdx;
|
||||
int32_t caseRunNum;
|
||||
} CaseCtrl;
|
||||
|
||||
CaseCtrl gCaseCtrl = {
|
||||
|
@ -133,6 +134,8 @@ CaseCtrl gCaseCtrl = {
|
|||
.checkParamNum = false,
|
||||
.printRes = true,
|
||||
.runTimes = 0,
|
||||
.caseIdx = -1,
|
||||
.caseRunNum = -1,
|
||||
};
|
||||
|
||||
int32_t taosGetTimeOfDay(struct timeval *tv) {
|
||||
|
@ -4147,7 +4150,6 @@ void prepare(TAOS *taos, int32_t colNum, int32_t *colList, int autoCreate) {
|
|||
exit(1);
|
||||
}
|
||||
taos_free_result(result);
|
||||
sleep(2); //TODO REMOVE IT
|
||||
|
||||
result = taos_query(taos, "use demo");
|
||||
taos_free_result(result);
|
||||
|
@ -4184,9 +4186,15 @@ void prepare(TAOS *taos, int32_t colNum, int32_t *colList, int autoCreate) {
|
|||
|
||||
void* runcase(TAOS *taos) {
|
||||
TAOS_STMT *stmt = NULL;
|
||||
int32_t caseIdx = 0;
|
||||
static int32_t caseIdx = 0;
|
||||
static int32_t caseRunNum = 0;
|
||||
int64_t beginUs, endUs, totalUs;
|
||||
|
||||
for (int32_t i = 0; i < sizeof(gCase)/sizeof(gCase[0]); ++i) {
|
||||
if (gCaseCtrl.caseRunNum > 0 && caseRunNum >= gCaseCtrl.caseRunNum) {
|
||||
break;
|
||||
}
|
||||
|
||||
CaseCfg cfg = gCase[i];
|
||||
gCurCase = &cfg;
|
||||
|
||||
|
@ -4194,7 +4202,10 @@ void* runcase(TAOS *taos) {
|
|||
continue;
|
||||
}
|
||||
|
||||
printf("* Case %d - %s Begin *\n", caseIdx, gCurCase->caseDesc);
|
||||
if (gCaseCtrl.caseIdx >= 0 && caseIdx < gCaseCtrl.caseIdx) {
|
||||
caseIdx++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (gCaseCtrl.runTimes) {
|
||||
gCurCase->runTimes = gCaseCtrl.runTimes;
|
||||
|
@ -4221,10 +4232,15 @@ void* runcase(TAOS *taos) {
|
|||
gCurCase->bindColNum = gCaseCtrl.bindColTypeNum;
|
||||
gCurCase->fullCol = false;
|
||||
}
|
||||
|
||||
|
||||
printf("* Case %d - [%s]%s Begin *\n", caseIdx, gCaseCtrl.caseCatalog, gCurCase->caseDesc);
|
||||
|
||||
totalUs = 0;
|
||||
for (int32_t n = 0; n < gCurCase->runTimes; ++n) {
|
||||
prepare(taos, gCurCase->colNum, gCurCase->colList, gCurCase->autoCreate);
|
||||
|
||||
|
||||
beginUs = taosGetTimestampUs();
|
||||
|
||||
stmt = taos_stmt_init(taos);
|
||||
if (NULL == stmt) {
|
||||
printf("taos_stmt_init failed, error:%s\n", taos_stmt_errstr(stmt));
|
||||
|
@ -4233,62 +4249,73 @@ void* runcase(TAOS *taos) {
|
|||
|
||||
(*gCurCase->runFn)(stmt);
|
||||
|
||||
prepareCheckResult(taos);
|
||||
|
||||
taos_stmt_close(stmt);
|
||||
|
||||
endUs = taosGetTimestampUs();
|
||||
totalUs += (endUs - beginUs);
|
||||
|
||||
prepareCheckResult(taos);
|
||||
}
|
||||
|
||||
printf("* Case %d - %s End *\n", caseIdx, gCurCase->caseDesc);
|
||||
printf("* Case %d - [%s]%s [AvgTime:%.3fms] End *\n", caseIdx, gCaseCtrl.caseCatalog, gCurCase->caseDesc, ((double)totalUs)/1000/gCurCase->runTimes);
|
||||
|
||||
caseIdx++;
|
||||
caseRunNum++;
|
||||
}
|
||||
|
||||
printf("test end\n");
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
void runAll(TAOS *taos) {
|
||||
printf("Normal Test\n");
|
||||
strcpy(gCaseCtrl.caseCatalog, "Normal Test");
|
||||
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
||||
runcase(taos);
|
||||
|
||||
printf("Null Test\n");
|
||||
strcpy(gCaseCtrl.caseCatalog, "Null Test");
|
||||
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
||||
gCaseCtrl.bindNullNum = 1;
|
||||
runcase(taos);
|
||||
gCaseCtrl.bindNullNum = 0;
|
||||
|
||||
printf("Bind Row Test\n");
|
||||
strcpy(gCaseCtrl.caseCatalog, "Bind Row Test");
|
||||
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
||||
gCaseCtrl.bindRowNum = 1;
|
||||
runcase(taos);
|
||||
gCaseCtrl.bindRowNum = 0;
|
||||
|
||||
printf("Row Num Test\n");
|
||||
strcpy(gCaseCtrl.caseCatalog, "Row Num Test");
|
||||
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
||||
gCaseCtrl.rowNum = 1000;
|
||||
gCaseCtrl.printRes = false;
|
||||
runcase(taos);
|
||||
gCaseCtrl.rowNum = 0;
|
||||
gCaseCtrl.printRes = true;
|
||||
|
||||
printf("Runtimes Test\n");
|
||||
strcpy(gCaseCtrl.caseCatalog, "Runtimes Test");
|
||||
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
||||
gCaseCtrl.runTimes = 2;
|
||||
runcase(taos);
|
||||
gCaseCtrl.runTimes = 0;
|
||||
|
||||
printf("Check Param Test\n");
|
||||
strcpy(gCaseCtrl.caseCatalog, "Check Param Test");
|
||||
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
||||
gCaseCtrl.checkParamNum = true;
|
||||
runcase(taos);
|
||||
gCaseCtrl.checkParamNum = false;
|
||||
|
||||
printf("Bind Col Num Test\n");
|
||||
strcpy(gCaseCtrl.caseCatalog, "Bind Col Num Test");
|
||||
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
||||
gCaseCtrl.bindColNum = 6;
|
||||
runcase(taos);
|
||||
gCaseCtrl.bindColNum = 0;
|
||||
|
||||
printf("Bind Col Type Test\n");
|
||||
strcpy(gCaseCtrl.caseCatalog, "Bind Col Type Test");
|
||||
printf("%s Begin\n", gCaseCtrl.caseCatalog);
|
||||
gCaseCtrl.bindColTypeNum = tListLen(bindColTypeList);
|
||||
gCaseCtrl.bindColTypeList = bindColTypeList;
|
||||
runcase(taos);
|
||||
|
||||
printf("All Test End\n");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
system sh/stop_dnodes.sh
|
||||
|
||||
system sh/deploy.sh -n dnode1 -i 1
|
||||
system sh/cfg.sh -n dnode1 -c wallevel -v 2
|
||||
system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1
|
||||
|
||||
print ========= start dnode1 as LEADER
|
||||
system sh/exec.sh -n dnode1 -s start
|
||||
sleep 2000
|
||||
sql connect
|
||||
|
||||
print ======== step1
|
||||
sql create database db1 vgroups 3;
|
||||
sql use db1;
|
||||
sql show databases;
|
||||
sql create stable st1 (ts timestamp, f1 int, f2 binary(200)) tags(t1 int);
|
||||
sql create stable st2 (ts timestamp, f1 int, f2 binary(200)) tags(t1 int);
|
||||
sql create table tb1 using st1 tags(1);
|
||||
sql insert into tb1 values (now, 1, "Hash Join (cost=230.47..713.98 rows=101 width=488) (actual time=0.711..7.427 rows=100 loops=1)");
|
||||
|
||||
sql create table tb2 using st1 tags(2);
|
||||
sql insert into tb2 values (now, 2, "Seq Scan on tenk2 t2 (cost=0.00..445.00 rows=10000 width=244) (actual time=0.007..2.583 rows=10000 loops=1)");
|
||||
sql create table tb3 using st1 tags(3);
|
||||
sql insert into tb3 values (now, 3, "Hash (cost=229.20..229.20 rows=101 width=244) (actual time=0.659..0.659 rows=100 loops=1)");
|
||||
sql create table tb4 using st1 tags(4);
|
||||
sql insert into tb4 values (now, 4, "Bitmap Heap Scan on tenk1 t1 (cost=5.07..229.20 rows=101 width=244) (actual time=0.080..0.526 rows=100 loops=1)");
|
||||
|
||||
sql create table tb1 using st2 tags(1);
|
||||
sql insert into tb1 values (now, 1, "Hash Join (cost=230.47..713.98 rows=101 width=488) (actual time=0.711..7.427 rows=100 loops=1)");
|
||||
|
||||
sql create table tb2 using st2 tags(2);
|
||||
sql insert into tb2 values (now, 2, "Seq Scan on tenk2 t2 (cost=0.00..445.00 rows=10000 width=244) (actual time=0.007..2.583 rows=10000 loops=1)");
|
||||
sql create table tb3 using st2 tags(3);
|
||||
sql insert into tb3 values (now, 3, "Hash (cost=229.20..229.20 rows=101 width=244) (actual time=0.659..0.659 rows=100 loops=1)");
|
||||
sql create table tb4 using st2 tags(4);
|
||||
sql insert into tb4 values (now, 4, "Bitmap Heap Scan on tenk1 t1 (cost=5.07..229.20 rows=101 width=244) (actual time=0.080..0.526 rows=100 loops=1)");
|
||||
|
||||
|
||||
print ======== step2
|
||||
sql explain select * from st1 where -2;
|
||||
sql explain select ts from tb1;
|
||||
sql explain select * from st1;
|
||||
sql explain select * from st1 order by ts;
|
||||
sql explain select * from information_schema.user_stables;
|
||||
sql explain select count(*),sum(f1) from tb1;
|
||||
sql explain select count(*),sum(f1) from st1;
|
||||
sql explain select count(*),sum(f1) from st1 group by f1;
|
||||
#sql explain select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
|
||||
sql explain select min(f1) from st1 interval(1m, 2a) sliding(30s);
|
||||
|
||||
print ======== step3
|
||||
sql explain verbose true select * from st1 where -2;
|
||||
sql explain verbose true select ts from tb1 where f1 > 0;
|
||||
sql explain verbose true select * from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
|
||||
sql explain verbose true select * from information_schema.user_stables where db_name='db2';
|
||||
sql explain verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0;
|
||||
|
||||
print ======== step4
|
||||
sql explain analyze select ts from st1 where -2;
|
||||
sql explain analyze select ts from tb1;
|
||||
sql explain analyze select ts from st1;
|
||||
sql explain analyze select ts from st1;
|
||||
sql explain analyze select ts from st1 order by ts;
|
||||
sql explain analyze select * from information_schema.user_stables;
|
||||
sql explain analyze select count(*),sum(f1) from tb1;
|
||||
sql explain analyze select count(*),sum(f1) from st1;
|
||||
sql explain analyze select count(*),sum(f1) from st1 group by f1;
|
||||
#sql explain analyze select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
|
||||
sql explain analyze select min(f1) from st1 interval(3m, 2a) sliding(1m);
|
||||
|
||||
print ======== step5
|
||||
sql explain analyze verbose true select ts from st1 where -2;
|
||||
sql explain analyze verbose true select ts from tb1;
|
||||
sql explain analyze verbose true select ts from st1;
|
||||
sql explain analyze verbose true select ts from st1;
|
||||
sql explain analyze verbose true select ts from st1 order by ts;
|
||||
sql explain analyze verbose true select * from information_schema.user_stables;
|
||||
sql explain analyze verbose true select count(*),sum(f1) from tb1;
|
||||
sql explain analyze verbose true select count(*),sum(f1) from st1;
|
||||
sql explain analyze verbose true select count(*),sum(f1) from st1 group by f1;
|
||||
#sql explain analyze verbose true select count(f1) from tb1 interval(10s, 2s) sliding(3s) fill(prev);
|
||||
sql explain analyze verbose true select ts from tb1 where f1 > 0;
|
||||
sql explain analyze verbose true select f1 from st1 where f1 > 0 and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00';
|
||||
sql explain analyze verbose true select * from information_schema.user_stables where db_name='db2';
|
||||
sql explain analyze verbose true select count(*),sum(f1) from st1 where f1 > 0 and ts > '2021-10-31 00:00:00' group by f1 having sum(f1) > 0;
|
||||
sql explain analyze verbose true select min(f1) from st1 interval(3m, 2a) sliding(1m);
|
||||
sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0;
|
||||
|
||||
#not pass case
|
||||
#sql explain verbose true select count(*),sum(f1) as aa from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by aa;
|
||||
#sql explain verbose true select * from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
|
||||
#sql explain verbose true select count(*),sum(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by ts;
|
||||
#sql explain verbose true select count(f1) from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(10s, 2s) sliding(3s) order by ts;
|
||||
#sql explain verbose true select min(f1) from st1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' interval(1m, 2a) sliding(30s) fill(linear) order by ts;
|
||||
#sql explain select max(f1) from tb1 SESSION(ts, 1s);
|
||||
#sql explain select max(f1) from st1 SESSION(ts, 1s);
|
||||
#sql explain select * from tb1, tb2 where tb1.ts=tb2.ts;
|
||||
#sql explain select * from st1, st2 where tb1.ts=tb2.ts;
|
||||
#sql explain analyze verbose true select sum(a+b) from (select _rowts, min(f1) b,count(*) a from st1 where f1 > 0 interval(1a)) where a < 0 interval(1s);
|
||||
|
||||
|
||||
system sh/exec.sh -n dnode1 -s stop -x SIGINT
|
Loading…
Reference in New Issue