Merge pull request #14543 from taosdata/feature/3.0_debug_wxy
fix: execution plan problem in the mode of using qnode as much as possible
This commit is contained in:
commit
cf9a6deaa5
|
@ -15,10 +15,10 @@
|
||||||
|
|
||||||
#include "builtins.h"
|
#include "builtins.h"
|
||||||
#include "builtinsimpl.h"
|
#include "builtinsimpl.h"
|
||||||
|
#include "cJSON.h"
|
||||||
#include "querynodes.h"
|
#include "querynodes.h"
|
||||||
#include "scalar.h"
|
#include "scalar.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "cJSON.h"
|
|
||||||
|
|
||||||
static int32_t buildFuncErrMsg(char* pErrBuf, int32_t len, int32_t errCode, const char* pFormat, ...) {
|
static int32_t buildFuncErrMsg(char* pErrBuf, int32_t len, int32_t errCode, const char* pFormat, ...) {
|
||||||
va_list vArgList;
|
va_list vArgList;
|
||||||
|
@ -52,10 +52,9 @@ static int32_t validateTimeUnitParam(uint8_t dbPrec, const SValueNode* pVal) {
|
||||||
return TIME_UNIT_TOO_SMALL;
|
return TIME_UNIT_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pVal->literal[0] != '1' || (pVal->literal[1] != 'u' && pVal->literal[1] != 'a' &&
|
if (pVal->literal[0] != '1' ||
|
||||||
pVal->literal[1] != 's' && pVal->literal[1] != 'm' &&
|
(pVal->literal[1] != 'u' && pVal->literal[1] != 'a' && pVal->literal[1] != 's' && pVal->literal[1] != 'm' &&
|
||||||
pVal->literal[1] != 'h' && pVal->literal[1] != 'd' &&
|
pVal->literal[1] != 'h' && pVal->literal[1] != 'd' && pVal->literal[1] != 'w')) {
|
||||||
pVal->literal[1] != 'w')) {
|
|
||||||
return TIME_UNIT_INVALID;
|
return TIME_UNIT_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -696,12 +695,13 @@ static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len
|
||||||
|
|
||||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||||
|
|
||||||
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode *)nodesListGetNode(pFunc->pParameterList, 1));
|
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1));
|
||||||
if (ret == TIME_UNIT_TOO_SMALL) {
|
if (ret == TIME_UNIT_TOO_SMALL) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"ELAPSED function time unit parameter should be greater than db precision");
|
"ELAPSED function time unit parameter should be greater than db precision");
|
||||||
} else if (ret == TIME_UNIT_INVALID) {
|
} else if (ret == TIME_UNIT_INVALID) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(
|
||||||
|
pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"ELAPSED function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
"ELAPSED function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -815,13 +815,13 @@ static int8_t validateHistogramBinType(char* binTypeStr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* errMsg, int32_t msgLen) {
|
static bool validateHistogramBinDesc(char* binDescStr, int8_t binType, char* errMsg, int32_t msgLen) {
|
||||||
const char *msg1 = "HISTOGRAM function requires four parameters";
|
const char* msg1 = "HISTOGRAM function requires four parameters";
|
||||||
const char *msg3 = "HISTOGRAM function invalid format for binDesc parameter";
|
const char* msg3 = "HISTOGRAM function invalid format for binDesc parameter";
|
||||||
const char *msg4 = "HISTOGRAM function binDesc parameter \"count\" should be in range [1, 1000]";
|
const char* msg4 = "HISTOGRAM function binDesc parameter \"count\" should be in range [1, 1000]";
|
||||||
const char *msg5 = "HISTOGRAM function bin/parameter should be in range [-DBL_MAX, DBL_MAX]";
|
const char* msg5 = "HISTOGRAM function bin/parameter should be in range [-DBL_MAX, DBL_MAX]";
|
||||||
const char *msg6 = "HISTOGRAM function binDesc parameter \"width\" cannot be 0";
|
const char* msg6 = "HISTOGRAM function binDesc parameter \"width\" cannot be 0";
|
||||||
const char *msg7 = "HISTOGRAM function binDesc parameter \"start\" cannot be 0 with \"log_bin\" type";
|
const char* msg7 = "HISTOGRAM function binDesc parameter \"start\" cannot be 0 with \"log_bin\" type";
|
||||||
const char *msg8 = "HISTOGRAM function binDesc parameter \"factor\" cannot be negative or equal to 0/1";
|
const char* msg8 = "HISTOGRAM function binDesc parameter \"factor\" cannot be negative or equal to 0/1";
|
||||||
|
|
||||||
cJSON* binDesc = cJSON_Parse(binDescStr);
|
cJSON* binDesc = cJSON_Parse(binDescStr);
|
||||||
int32_t numOfBins;
|
int32_t numOfBins;
|
||||||
|
@ -1218,12 +1218,13 @@ static int32_t translateStateDuration(SFunctionNode* pFunc, char* pErrBuf, int32
|
||||||
if (numOfParams == 4) {
|
if (numOfParams == 4) {
|
||||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||||
|
|
||||||
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode *)nodesListGetNode(pFunc->pParameterList, 3));
|
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 3));
|
||||||
if (ret == TIME_UNIT_TOO_SMALL) {
|
if (ret == TIME_UNIT_TOO_SMALL) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"STATEDURATION function time unit parameter should be greater than db precision");
|
"STATEDURATION function time unit parameter should be greater than db precision");
|
||||||
} else if (ret == TIME_UNIT_INVALID) {
|
} else if (ret == TIME_UNIT_INVALID) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(
|
||||||
|
pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"STATEDURATION function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
"STATEDURATION function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1432,10 +1433,6 @@ static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t l
|
||||||
|
|
||||||
static int32_t translateFirstLastImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isPartial) {
|
static int32_t translateFirstLastImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isPartial) {
|
||||||
// first(col_list) will be rewritten as first(col)
|
// first(col_list) will be rewritten as first(col)
|
||||||
if (2 != LIST_LENGTH(pFunc->pParameterList)) { // input has two params c0,ts, is this a bug?
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0);
|
SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0);
|
||||||
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
uint8_t paraType = ((SExprNode*)pPara)->resType.type;
|
||||||
int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes;
|
int32_t paraBytes = ((SExprNode*)pPara)->resType.bytes;
|
||||||
|
@ -1733,12 +1730,13 @@ static int32_t translateTimeTruncate(SFunctionNode* pFunc, char* pErrBuf, int32_
|
||||||
// add database precision as param
|
// add database precision as param
|
||||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||||
|
|
||||||
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode *)nodesListGetNode(pFunc->pParameterList, 1));
|
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1));
|
||||||
if (ret == TIME_UNIT_TOO_SMALL) {
|
if (ret == TIME_UNIT_TOO_SMALL) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"TIMETRUNCATE function time unit parameter should be greater than db precision");
|
"TIMETRUNCATE function time unit parameter should be greater than db precision");
|
||||||
} else if (ret == TIME_UNIT_INVALID) {
|
} else if (ret == TIME_UNIT_INVALID) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(
|
||||||
|
pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"TIMETRUNCATE function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
"TIMETRUNCATE function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1772,12 +1770,13 @@ static int32_t translateTimeDiff(SFunctionNode* pFunc, char* pErrBuf, int32_t le
|
||||||
uint8_t dbPrec = pFunc->node.resType.precision;
|
uint8_t dbPrec = pFunc->node.resType.precision;
|
||||||
|
|
||||||
if (3 == numOfParams) {
|
if (3 == numOfParams) {
|
||||||
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode *)nodesListGetNode(pFunc->pParameterList, 2));
|
int32_t ret = validateTimeUnitParam(dbPrec, (SValueNode*)nodesListGetNode(pFunc->pParameterList, 2));
|
||||||
if (ret == TIME_UNIT_TOO_SMALL) {
|
if (ret == TIME_UNIT_TOO_SMALL) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"TIMEDIFF function time unit parameter should be greater than db precision");
|
"TIMEDIFF function time unit parameter should be greater than db precision");
|
||||||
} else if (ret == TIME_UNIT_INVALID) {
|
} else if (ret == TIME_UNIT_INVALID) {
|
||||||
return buildFuncErrMsg(pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
return buildFuncErrMsg(
|
||||||
|
pErrBuf, len, TSDB_CODE_FUNC_FUNTION_ERROR,
|
||||||
"TIMEDIFF function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
"TIMEDIFF function time unit parameter should be one of the following: [1u, 1a, 1s, 1m, 1h, 1d, 1w]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -385,6 +385,15 @@ SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType typ
|
||||||
|
|
||||||
SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight) {
|
SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
|
if (OP_TYPE_MINUS == type && QUERY_NODE_VALUE == nodeType(pLeft)) {
|
||||||
|
SValueNode* pVal = (SValueNode*)pLeft;
|
||||||
|
char* pNewLiteral = taosMemoryCalloc(1, strlen(pVal->literal) + 2);
|
||||||
|
CHECK_OUT_OF_MEM(pNewLiteral);
|
||||||
|
sprintf(pNewLiteral, "-%s", pVal->literal);
|
||||||
|
taosMemoryFree(pVal->literal);
|
||||||
|
pVal->literal = pNewLiteral;
|
||||||
|
return pLeft;
|
||||||
|
}
|
||||||
SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||||
CHECK_OUT_OF_MEM(op);
|
CHECK_OUT_OF_MEM(op);
|
||||||
op->opType = type;
|
op->opType = type;
|
||||||
|
|
|
@ -558,11 +558,11 @@ static void setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColum
|
||||||
pCol->node.resType = pExpr->resType;
|
pCol->node.resType = pExpr->resType;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* pTable, SNodeList* pList) {
|
static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* pTable, bool igTags, SNodeList* pList) {
|
||||||
if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
|
if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
|
||||||
const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta;
|
const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta;
|
||||||
int32_t nums =
|
int32_t nums = pMeta->tableInfo.numOfColumns +
|
||||||
pMeta->tableInfo.numOfColumns + ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0);
|
(igTags ? 0 : ((TSDB_SUPER_TABLE == pMeta->tableType) ? pMeta->tableInfo.numOfTags : 0));
|
||||||
for (int32_t i = 0; i < nums; ++i) {
|
for (int32_t i = 0; i < nums; ++i) {
|
||||||
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN);
|
||||||
if (NULL == pCol) {
|
if (NULL == pCol) {
|
||||||
|
@ -878,6 +878,9 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal,
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_VARCHAR:
|
case TSDB_DATA_TYPE_VARCHAR:
|
||||||
case TSDB_DATA_TYPE_VARBINARY: {
|
case TSDB_DATA_TYPE_VARBINARY: {
|
||||||
|
if (strict && (pVal->node.resType.bytes > targetDt.bytes - VARSTR_HEADER_SIZE)) {
|
||||||
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal);
|
||||||
|
}
|
||||||
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
|
pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1);
|
||||||
if (NULL == pVal->datum.p) {
|
if (NULL == pVal->datum.p) {
|
||||||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
@ -1333,6 +1336,9 @@ static int32_t rewriteSystemInfoFuncImpl(STranslateContext* pCxt, char* pLiteral
|
||||||
pVal->isNull = true;
|
pVal->isNull = true;
|
||||||
} else {
|
} else {
|
||||||
pVal->literal = pLiteral;
|
pVal->literal = pLiteral;
|
||||||
|
if (IS_VAR_DATA_TYPE(pVal->node.resType.type)) {
|
||||||
|
pVal->node.resType.bytes = strlen(pLiteral);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (DEAL_RES_ERROR != translateValue(pCxt, pVal)) {
|
if (DEAL_RES_ERROR != translateValue(pCxt, pVal)) {
|
||||||
*pNode = (SNode*)pVal;
|
*pNode = (SNode*)pVal;
|
||||||
|
@ -1928,7 +1934,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
|
static int32_t createAllColumns(STranslateContext* pCxt, bool igTags, SNodeList** pCols) {
|
||||||
*pCols = nodesMakeList();
|
*pCols = nodesMakeList();
|
||||||
if (NULL == *pCols) {
|
if (NULL == *pCols) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
||||||
|
@ -1937,7 +1943,7 @@ static int32_t createAllColumns(STranslateContext* pCxt, SNodeList** pCols) {
|
||||||
size_t nums = taosArrayGetSize(pTables);
|
size_t nums = taosArrayGetSize(pTables);
|
||||||
for (size_t i = 0; i < nums; ++i) {
|
for (size_t i = 0; i < nums; ++i) {
|
||||||
STableNode* pTable = taosArrayGetP(pTables, i);
|
STableNode* pTable = taosArrayGetP(pTables, i);
|
||||||
int32_t code = createColumnsByTable(pCxt, pTable, *pCols);
|
int32_t code = createColumnsByTable(pCxt, pTable, igTags, *pCols);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1974,7 +1980,7 @@ static SNode* createMultiResFunc(SFunctionNode* pSrcFunc, SExprNode* pExpr) {
|
||||||
return (SNode*)pFunc;
|
return (SNode*)pFunc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SNodeList** pOutput) {
|
static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, bool igTags, SNodeList** pOutput) {
|
||||||
STableNode* pTable = NULL;
|
STableNode* pTable = NULL;
|
||||||
int32_t code = findTable(pCxt, pCol->tableAlias, &pTable);
|
int32_t code = findTable(pCxt, pCol->tableAlias, &pTable);
|
||||||
if (TSDB_CODE_SUCCESS == code && NULL == *pOutput) {
|
if (TSDB_CODE_SUCCESS == code && NULL == *pOutput) {
|
||||||
|
@ -1984,7 +1990,7 @@ static int32_t createTableAllCols(STranslateContext* pCxt, SColumnNode* pCol, SN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = createColumnsByTable(pCxt, pTable, *pOutput);
|
code = createColumnsByTable(pCxt, pTable, igTags, *pOutput);
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -2006,11 +2012,9 @@ static int32_t createMultiResFuncsParas(STranslateContext* pCxt, SNodeList* pSrc
|
||||||
SNode* pPara = NULL;
|
SNode* pPara = NULL;
|
||||||
FOREACH(pPara, pSrcParas) {
|
FOREACH(pPara, pSrcParas) {
|
||||||
if (isStar(pPara)) {
|
if (isStar(pPara)) {
|
||||||
code = createAllColumns(pCxt, &pExprs);
|
code = createAllColumns(pCxt, true, &pExprs);
|
||||||
// The syntax definition ensures that * and other parameters do not appear at the same time
|
|
||||||
break;
|
|
||||||
} else if (isTableStar(pPara)) {
|
} else if (isTableStar(pPara)) {
|
||||||
code = createTableAllCols(pCxt, (SColumnNode*)pPara, &pExprs);
|
code = createTableAllCols(pCxt, (SColumnNode*)pPara, true, &pExprs);
|
||||||
} else {
|
} else {
|
||||||
code = nodesListMakeStrictAppend(&pExprs, nodesCloneNode(pPara));
|
code = nodesListMakeStrictAppend(&pExprs, nodesCloneNode(pPara));
|
||||||
}
|
}
|
||||||
|
@ -2069,7 +2073,7 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (isStar(pNode)) {
|
if (isStar(pNode)) {
|
||||||
SNodeList* pCols = NULL;
|
SNodeList* pCols = NULL;
|
||||||
code = createAllColumns(pCxt, &pCols);
|
code = createAllColumns(pCxt, false, &pCols);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
INSERT_LIST(pSelect->pProjectionList, pCols);
|
INSERT_LIST(pSelect->pProjectionList, pCols);
|
||||||
ERASE_NODE(pSelect->pProjectionList);
|
ERASE_NODE(pSelect->pProjectionList);
|
||||||
|
@ -2085,7 +2089,7 @@ static int32_t translateStar(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
}
|
}
|
||||||
} else if (isTableStar(pNode)) {
|
} else if (isTableStar(pNode)) {
|
||||||
SNodeList* pCols = NULL;
|
SNodeList* pCols = NULL;
|
||||||
code = createTableAllCols(pCxt, (SColumnNode*)pNode, &pCols);
|
code = createTableAllCols(pCxt, (SColumnNode*)pNode, false, &pCols);
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
INSERT_LIST(pSelect->pProjectionList, pCols);
|
INSERT_LIST(pSelect->pProjectionList, pCols);
|
||||||
ERASE_NODE(pSelect->pProjectionList);
|
ERASE_NODE(pSelect->pProjectionList);
|
||||||
|
@ -5826,10 +5830,6 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
|
||||||
return pCxt->errCode;
|
return pCxt->errCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_VAR_DATA_TYPE(pSchema->type) && strlen(pStmt->pVal->literal) > pSchema->bytes) {
|
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pStmt->pVal->literal);
|
|
||||||
}
|
|
||||||
|
|
||||||
pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type);
|
pReq->isNull = (TSDB_DATA_TYPE_NULL == pStmt->pVal->node.resType.type);
|
||||||
if (targetDt.type == TSDB_DATA_TYPE_JSON) {
|
if (targetDt.type == TSDB_DATA_TYPE_JSON) {
|
||||||
pReq->isNull = 0;
|
pReq->isNull = 0;
|
||||||
|
|
|
@ -236,7 +236,6 @@ int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo, const char*
|
||||||
|
|
||||||
const char* prefix = "syntax error";
|
const char* prefix = "syntax error";
|
||||||
if (sourceStr == NULL) {
|
if (sourceStr == NULL) {
|
||||||
assert(additionalInfo != NULL);
|
|
||||||
snprintf(pBuf->buf, pBuf->len, msgFormat1, additionalInfo);
|
snprintf(pBuf->buf, pBuf->len, msgFormat1, additionalInfo);
|
||||||
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
|
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -254,40 +253,25 @@ int32_t buildSyntaxErrMsg(SMsgBuf* pBuf, const char* additionalInfo, const char*
|
||||||
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
|
return TSDB_CODE_TSC_SQL_SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* getTableColumnSchema(const STableMeta* pTableMeta) {
|
SSchema* getTableColumnSchema(const STableMeta* pTableMeta) { return (SSchema*)pTableMeta->schema; }
|
||||||
assert(pTableMeta != NULL);
|
|
||||||
return (SSchema*)pTableMeta->schema;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SSchema* getOneColumnSchema(const STableMeta* pTableMeta, int32_t colIndex) {
|
static SSchema* getOneColumnSchema(const STableMeta* pTableMeta, int32_t colIndex) {
|
||||||
assert(pTableMeta != NULL && pTableMeta->schema != NULL && colIndex >= 0 &&
|
|
||||||
colIndex < (getNumOfColumns(pTableMeta) + getNumOfTags(pTableMeta)));
|
|
||||||
|
|
||||||
SSchema* pSchema = (SSchema*)pTableMeta->schema;
|
SSchema* pSchema = (SSchema*)pTableMeta->schema;
|
||||||
return &pSchema[colIndex];
|
return &pSchema[colIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
SSchema* getTableTagSchema(const STableMeta* pTableMeta) {
|
SSchema* getTableTagSchema(const STableMeta* pTableMeta) {
|
||||||
assert(pTableMeta != NULL &&
|
|
||||||
(pTableMeta->tableType == TSDB_SUPER_TABLE || pTableMeta->tableType == TSDB_CHILD_TABLE));
|
|
||||||
return getOneColumnSchema(pTableMeta, getTableInfo(pTableMeta).numOfColumns);
|
return getOneColumnSchema(pTableMeta, getTableInfo(pTableMeta).numOfColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getNumOfColumns(const STableMeta* pTableMeta) {
|
int32_t getNumOfColumns(const STableMeta* pTableMeta) {
|
||||||
assert(pTableMeta != NULL);
|
|
||||||
// table created according to super table, use data from super table
|
// table created according to super table, use data from super table
|
||||||
return getTableInfo(pTableMeta).numOfColumns;
|
return getTableInfo(pTableMeta).numOfColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getNumOfTags(const STableMeta* pTableMeta) {
|
int32_t getNumOfTags(const STableMeta* pTableMeta) { return getTableInfo(pTableMeta).numOfTags; }
|
||||||
assert(pTableMeta != NULL);
|
|
||||||
return getTableInfo(pTableMeta).numOfTags;
|
|
||||||
}
|
|
||||||
|
|
||||||
STableComInfo getTableInfo(const STableMeta* pTableMeta) {
|
STableComInfo getTableInfo(const STableMeta* pTableMeta) { return pTableMeta->tableInfo; }
|
||||||
assert(pTableMeta != NULL);
|
|
||||||
return pTableMeta->tableInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
STableMeta* tableMetaDup(const STableMeta* pTableMeta) {
|
STableMeta* tableMetaDup(const STableMeta* pTableMeta) {
|
||||||
size_t size = TABLE_META_SIZE(pTableMeta);
|
size_t size = TABLE_META_SIZE(pTableMeta);
|
||||||
|
|
|
@ -75,6 +75,11 @@ static SLogicNode* optFindPossibleNode(SLogicNode* pNode, FMayBeOptimized func)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void optResetParent(SLogicNode* pNode) {
|
||||||
|
SNode* pChild = NULL;
|
||||||
|
FOREACH(pChild, pNode->pChildren) { ((SLogicNode*)pChild)->pParent = pNode; }
|
||||||
|
}
|
||||||
|
|
||||||
EDealRes scanPathOptHaveNormalColImpl(SNode* pNode, void* pContext) {
|
EDealRes scanPathOptHaveNormalColImpl(SNode* pNode, void* pContext) {
|
||||||
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
|
||||||
// *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType);
|
// *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType);
|
||||||
|
@ -1540,6 +1545,7 @@ static int32_t rewriteTailOptCreateSort(SIndefRowsFuncLogicNode* pIndef, SLogicN
|
||||||
|
|
||||||
pSort->groupSort = rewriteTailOptNeedGroupSort(pIndef);
|
pSort->groupSort = rewriteTailOptNeedGroupSort(pIndef);
|
||||||
TSWAP(pSort->node.pChildren, pIndef->node.pChildren);
|
TSWAP(pSort->node.pChildren, pIndef->node.pChildren);
|
||||||
|
optResetParent((SLogicNode*)pSort);
|
||||||
pSort->node.precision = pIndef->node.precision;
|
pSort->node.precision = pIndef->node.precision;
|
||||||
|
|
||||||
SFunctionNode* pTail = NULL;
|
SFunctionNode* pTail = NULL;
|
||||||
|
@ -1747,6 +1753,7 @@ static int32_t rewriteUniqueOptCreateAgg(SIndefRowsFuncLogicNode* pIndef, SLogic
|
||||||
}
|
}
|
||||||
|
|
||||||
TSWAP(pAgg->node.pChildren, pIndef->node.pChildren);
|
TSWAP(pAgg->node.pChildren, pIndef->node.pChildren);
|
||||||
|
optResetParent((SLogicNode*)pAgg);
|
||||||
pAgg->node.precision = pIndef->node.precision;
|
pAgg->node.precision = pIndef->node.precision;
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -1203,7 +1203,8 @@ typedef struct SQnodeSplitInfo {
|
||||||
|
|
||||||
static bool qndSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode,
|
static bool qndSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode,
|
||||||
SQnodeSplitInfo* pInfo) {
|
SQnodeSplitInfo* pInfo) {
|
||||||
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode) && NULL != pNode->pParent) {
|
if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode) && NULL != pNode->pParent &&
|
||||||
|
((SScanLogicNode*)pNode)->scanSeq[0] < 1 && ((SScanLogicNode*)pNode)->scanSeq[1] < 1) {
|
||||||
pInfo->pSplitNode = pNode;
|
pInfo->pSplitNode = pNode;
|
||||||
pInfo->pSubplan = pSubplan;
|
pInfo->pSubplan = pSubplan;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -63,6 +63,10 @@ TEST_F(PlanBasicTest, uniqueFunc) {
|
||||||
run("SELECT UNIQUE(c2 + 10), ts, c2 FROM t1 WHERE c1 > 10");
|
run("SELECT UNIQUE(c2 + 10), ts, c2 FROM t1 WHERE c1 > 10");
|
||||||
|
|
||||||
run("SELECT UNIQUE(c1) a FROM t1 ORDER BY a");
|
run("SELECT UNIQUE(c1) a FROM t1 ORDER BY a");
|
||||||
|
|
||||||
|
run("SELECT ts, UNIQUE(c1) FROM st1 PARTITION BY TBNAME");
|
||||||
|
|
||||||
|
run("SELECT TBNAME, UNIQUE(c1) FROM st1 PARTITION BY TBNAME");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlanBasicTest, tailFunc) {
|
TEST_F(PlanBasicTest, tailFunc) {
|
||||||
|
@ -81,6 +85,8 @@ TEST_F(PlanBasicTest, tailFunc) {
|
||||||
run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 PARTITION BY c1 LIMIT 5");
|
run("SELECT TAIL(c2 + 10, 10, 80) FROM t1 WHERE c1 > 10 PARTITION BY c1 LIMIT 5");
|
||||||
|
|
||||||
run("SELECT TAIL(c1, 2, 1) FROM st1s1 UNION ALL SELECT c1 FROM st1s2");
|
run("SELECT TAIL(c1, 2, 1) FROM st1s1 UNION ALL SELECT c1 FROM st1s2");
|
||||||
|
|
||||||
|
run("SELECT TAIL(c1, 1) FROM st2 WHERE jtag->'tag1' > 10");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlanBasicTest, interpFunc) {
|
TEST_F(PlanBasicTest, interpFunc) {
|
||||||
|
|
|
@ -91,10 +91,3 @@ TEST_F(PlanOtherTest, delete) {
|
||||||
|
|
||||||
run("DELETE FROM st1 WHERE ts > now - 2d and ts < now - 1d AND tag1 = 10");
|
run("DELETE FROM st1 WHERE ts > now - 2d and ts < now - 1d AND tag1 = 10");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlanOtherTest, queryPolicy) {
|
|
||||||
useDb("root", "test");
|
|
||||||
|
|
||||||
tsQueryPolicy = QUERY_POLICY_QNODE;
|
|
||||||
run("SELECT COUNT(*) FROM st1");
|
|
||||||
}
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ static void parseArg(int argc, char* argv[]) {
|
||||||
{"skipSql", required_argument, NULL, 's'},
|
{"skipSql", required_argument, NULL, 's'},
|
||||||
{"limitSql", required_argument, NULL, 'i'},
|
{"limitSql", required_argument, NULL, 'i'},
|
||||||
{"log", required_argument, NULL, 'l'},
|
{"log", required_argument, NULL, 'l'},
|
||||||
|
{"queryPolicy", required_argument, NULL, 'q'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
@ -95,6 +96,9 @@ static void parseArg(int argc, char* argv[]) {
|
||||||
case 'l':
|
case 'l':
|
||||||
setLogLevel(optarg);
|
setLogLevel(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'q':
|
||||||
|
setQueryPolicy(optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "mockCatalogService.h"
|
#include "mockCatalogService.h"
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "planInt.h"
|
#include "planInt.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
@ -53,6 +54,7 @@ DumpModule g_dumpModule = DUMP_MODULE_NOTHING;
|
||||||
int32_t g_skipSql = 0;
|
int32_t g_skipSql = 0;
|
||||||
int32_t g_limitSql = 0;
|
int32_t g_limitSql = 0;
|
||||||
int32_t g_logLevel = 131;
|
int32_t g_logLevel = 131;
|
||||||
|
int32_t g_queryPolicy = QUERY_POLICY_VNODE;
|
||||||
|
|
||||||
void setDumpModule(const char* pModule) {
|
void setDumpModule(const char* pModule) {
|
||||||
if (NULL == pModule) {
|
if (NULL == pModule) {
|
||||||
|
@ -79,6 +81,7 @@ void setDumpModule(const char* pModule) {
|
||||||
void setSkipSqlNum(const char* pNum) { g_skipSql = stoi(pNum); }
|
void setSkipSqlNum(const char* pNum) { g_skipSql = stoi(pNum); }
|
||||||
void setLimitSqlNum(const char* pNum) { g_limitSql = stoi(pNum); }
|
void setLimitSqlNum(const char* pNum) { g_limitSql = stoi(pNum); }
|
||||||
void setLogLevel(const char* pLogLevel) { g_logLevel = stoi(pLogLevel); }
|
void setLogLevel(const char* pLogLevel) { g_logLevel = stoi(pLogLevel); }
|
||||||
|
void setQueryPolicy(const char* pQueryPolicy) { g_queryPolicy = stoi(pQueryPolicy); }
|
||||||
|
|
||||||
int32_t getLogLevel() { return g_logLevel; }
|
int32_t getLogLevel() { return g_logLevel; }
|
||||||
|
|
||||||
|
@ -105,7 +108,23 @@ class PlannerTestBaseImpl {
|
||||||
}
|
}
|
||||||
++sqlNum_;
|
++sqlNum_;
|
||||||
|
|
||||||
|
switch (g_queryPolicy) {
|
||||||
|
case QUERY_POLICY_VNODE:
|
||||||
|
case QUERY_POLICY_HYBRID:
|
||||||
|
case QUERY_POLICY_QNODE:
|
||||||
|
runImpl(sql, g_queryPolicy);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
runImpl(sql, QUERY_POLICY_VNODE);
|
||||||
|
runImpl(sql, QUERY_POLICY_HYBRID);
|
||||||
|
runImpl(sql, QUERY_POLICY_QNODE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void runImpl(const string& sql, int32_t queryPolicy) {
|
||||||
reset();
|
reset();
|
||||||
|
tsQueryPolicy = queryPolicy;
|
||||||
try {
|
try {
|
||||||
SQuery* pQuery = nullptr;
|
SQuery* pQuery = nullptr;
|
||||||
doParseSql(sql, &pQuery);
|
doParseSql(sql, &pQuery);
|
||||||
|
|
|
@ -45,6 +45,7 @@ extern void setDumpModule(const char* pModule);
|
||||||
extern void setSkipSqlNum(const char* pNum);
|
extern void setSkipSqlNum(const char* pNum);
|
||||||
extern void setLimitSqlNum(const char* pNum);
|
extern void setLimitSqlNum(const char* pNum);
|
||||||
extern void setLogLevel(const char* pLogLevel);
|
extern void setLogLevel(const char* pLogLevel);
|
||||||
|
extern void setQueryPolicy(const char* pQueryPolicy);
|
||||||
extern int32_t getLogLevel();
|
extern int32_t getLogLevel();
|
||||||
|
|
||||||
#endif // PLAN_TEST_UTIL_H
|
#endif // PLAN_TEST_UTIL_H
|
||||||
|
|
|
@ -14,7 +14,7 @@ sql_error alter table db.stb MODIFY tag ts int
|
||||||
sql_error alter table db.stb MODIFY tag t2 binary(3)
|
sql_error alter table db.stb MODIFY tag t2 binary(3)
|
||||||
sql_error alter table db.stb MODIFY tag t2 int
|
sql_error alter table db.stb MODIFY tag t2 int
|
||||||
sql_error alter table db.stb MODIFY tag t1 int
|
sql_error alter table db.stb MODIFY tag t1 int
|
||||||
sql create table db.ctb using db.stb tags(101, "12345")
|
sql create table db.ctb using db.stb tags(101, "123")
|
||||||
sql insert into db.ctb values(now, 1, "1234")
|
sql insert into db.ctb values(now, 1, "1234")
|
||||||
|
|
||||||
sql select * from db.stb
|
sql select * from db.stb
|
||||||
|
@ -32,7 +32,7 @@ endi
|
||||||
if $data[0][3] != 101 then
|
if $data[0][3] != 101 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][4] != 1234 then
|
if $data[0][4] != 123 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ sql_error alter table db.stb rename tag ts c3
|
||||||
sql_error alter table db.stb rename tag t2 t1
|
sql_error alter table db.stb rename tag t2 t1
|
||||||
sql_error alter table db.stb rename tag t2 t2
|
sql_error alter table db.stb rename tag t2 t2
|
||||||
sql_error alter table db.stb rename tag t1 t2
|
sql_error alter table db.stb rename tag t1 t2
|
||||||
sql create table db.ctb using db.stb tags(101, "12345")
|
sql create table db.ctb using db.stb tags(101, "123")
|
||||||
sql insert into db.ctb values(now, 1, "1234")
|
sql insert into db.ctb values(now, 1, "1234")
|
||||||
|
|
||||||
sql select * from db.stb
|
sql select * from db.stb
|
||||||
|
@ -32,7 +32,7 @@ endi
|
||||||
if $data[0][3] != 101 then
|
if $data[0][3] != 101 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][4] != 1234 then
|
if $data[0][4] != 123 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ endi
|
||||||
if $data[0][3] != 101 then
|
if $data[0][3] != 101 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
if $data[0][4] != 1234 then
|
if $data[0][4] != 123 then
|
||||||
return -1
|
return -1
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue