fix other platform error
This commit is contained in:
parent
cd9fcb37b8
commit
51fa1d40a4
|
@ -7800,7 +7800,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
|
|||
int32_t colSize = taosArrayGetSize(pReq->pCols);
|
||||
if (tEncodeI32(&encoder, colSize) < 0) return -1;
|
||||
for (int32_t i = 0; i < colSize; ++i) {
|
||||
SField *pField = taosArrayGet(pReq->pCols, i);
|
||||
SFieldWithOptions *pField = taosArrayGet(pReq->pCols, i);
|
||||
if (tEncodeI8(&encoder, pField->type) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pField->flags) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pField->bytes) < 0) return -1;
|
||||
|
|
|
@ -69,7 +69,6 @@ typedef struct SCollectJoinCondsContext {
|
|||
int32_t code;
|
||||
} SCollectJoinCondsContext;
|
||||
|
||||
|
||||
// clang-format off
|
||||
static const SSysTableShowAdapter sysTableShowAdapter[] = {
|
||||
{
|
||||
|
@ -323,7 +322,8 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery);
|
|||
static int32_t setRefreshMeta(STranslateContext* pCxt, SQuery* pQuery);
|
||||
|
||||
static bool isWindowJoinStmt(SSelectStmt* pSelect) {
|
||||
return (QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable)) && IS_WINDOW_JOIN(((SJoinTableNode*)pSelect->pFromTable)->subType);
|
||||
return (QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable)) &&
|
||||
IS_WINDOW_JOIN(((SJoinTableNode*)pSelect->pFromTable)->subType);
|
||||
}
|
||||
|
||||
static int32_t replacePsedudoColumnFuncWithColumn(STranslateContext* pCxt, SNode** ppNode);
|
||||
|
@ -937,7 +937,6 @@ static bool isCurGlobalTimeLineQuery(SNode* pStmt) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static bool isBlockTimeLineAlignedQuery(SNode* pStmt) {
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
||||
if (!isBlockTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) {
|
||||
|
@ -953,7 +952,6 @@ static bool isBlockTimeLineAlignedQuery(SNode* pStmt) {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
static bool isTimeLineAlignedQuery(SNode* pStmt) {
|
||||
SSelectStmt* pSelect = (SSelectStmt*)pStmt;
|
||||
if (!isTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) {
|
||||
|
@ -1078,8 +1076,7 @@ static void setColumnPrimTs(STranslateContext* pCxt, SColumnNode* pCol, const ST
|
|||
|
||||
bool joinQuery = false;
|
||||
SJoinTableNode* pJoinTable = NULL;
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pCxt->pCurrStmt) &&
|
||||
NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable &&
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pCxt->pCurrStmt) && NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable &&
|
||||
QUERY_NODE_JOIN_TABLE == nodeType(((SSelectStmt*)pCxt->pCurrStmt)->pFromTable)) {
|
||||
joinQuery = true;
|
||||
pJoinTable = (SJoinTableNode*)((SSelectStmt*)pCxt->pCurrStmt)->pFromTable;
|
||||
|
@ -1096,12 +1093,14 @@ static void setColumnPrimTs(STranslateContext* pCxt, SColumnNode* pCol, const ST
|
|||
pCol->isPrimTs = true;
|
||||
break;
|
||||
case JOIN_TYPE_LEFT:
|
||||
if (!IS_SEMI_JOIN(pJoinTable->subType) && 0 != strcmp(pTable->tableAlias, ((STableNode*)pJoinTable->pLeft)->tableAlias)) {
|
||||
if (!IS_SEMI_JOIN(pJoinTable->subType) &&
|
||||
0 != strcmp(pTable->tableAlias, ((STableNode*)pJoinTable->pLeft)->tableAlias)) {
|
||||
pCol->isPrimTs = false;
|
||||
}
|
||||
break;
|
||||
case JOIN_TYPE_RIGHT:
|
||||
if (!IS_SEMI_JOIN(pJoinTable->subType) && 0 != strcmp(pTable->tableAlias, ((STableNode*)pJoinTable->pRight)->tableAlias)) {
|
||||
if (!IS_SEMI_JOIN(pJoinTable->subType) &&
|
||||
0 != strcmp(pTable->tableAlias, ((STableNode*)pJoinTable->pRight)->tableAlias)) {
|
||||
pCol->isPrimTs = false;
|
||||
}
|
||||
break;
|
||||
|
@ -1111,7 +1110,6 @@ static void setColumnPrimTs(STranslateContext* pCxt, SColumnNode* pCol, const ST
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static int32_t createColumnsByTable(STranslateContext* pCxt, const STableNode* pTable, bool igTags, SNodeList* pList) {
|
||||
if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) {
|
||||
const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta;
|
||||
|
@ -1152,17 +1150,14 @@ static bool isInternalPrimaryKey(const SColumnNode* pCol) {
|
|||
(0 == strcmp(pCol->colName, ROWTS_PSEUDO_COLUMN_NAME) || 0 == strcmp(pCol->colName, C0_PSEUDO_COLUMN_NAME));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef, STableNode* pTable,
|
||||
bool* pFound, bool keepOriginTable) {
|
||||
static int32_t findAndSetColumn(STranslateContext* pCxt, SColumnNode** pColRef, STableNode* pTable, bool* pFound,
|
||||
bool keepOriginTable) {
|
||||
SColumnNode* pCol = *pColRef;
|
||||
*pFound = false;
|
||||
bool joinQuery = false;
|
||||
SJoinTableNode* pJoinTable = NULL;
|
||||
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pCxt->pCurrStmt) &&
|
||||
NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable &&
|
||||
if (QUERY_NODE_SELECT_STMT == nodeType(pCxt->pCurrStmt) && NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pFromTable &&
|
||||
QUERY_NODE_JOIN_TABLE == nodeType(((SSelectStmt*)pCxt->pCurrStmt)->pFromTable)) {
|
||||
joinQuery = true;
|
||||
pJoinTable = (SJoinTableNode*)((SSelectStmt*)pCxt->pCurrStmt)->pFromTable;
|
||||
|
@ -1602,7 +1597,6 @@ static EDealRes translateTimeOffsetValue(STranslateContext* pCxt, SValueNode* pV
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal, SDataType targetDt, bool strict) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
switch (targetDt.type) {
|
||||
|
@ -1951,7 +1945,6 @@ STableNode* getJoinProbeTable(STranslateContext* pCxt) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// count(*) is rewritten as count(ts) for scannning optimization
|
||||
static int32_t rewriteCountStar(STranslateContext* pCxt, SFunctionNode* pCount) {
|
||||
SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pCount->pParameterList, 0);
|
||||
|
@ -2180,8 +2173,6 @@ static int32_t translateInterpPseudoColumnFunc(STranslateContext* pCxt, SNode**
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int32_t translateTimelineFunc(STranslateContext* pCxt, SFunctionNode* pFunc) {
|
||||
if (!fmIsTimelineFunc(pFunc->funcId)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -2945,7 +2936,8 @@ static bool isWindowJoinProbeTablePrimCol(SSelectStmt* pSelect, SNode* p
|
|||
return false;
|
||||
}
|
||||
|
||||
if (pCol->colId == PRIMARYKEY_TIMESTAMP_COL_ID && 0 == strcmp(pCol->dbName, pProbeTable->table.dbName) && 0 == strcmp(pCol->tableAlias, pProbeTable->table.tableAlias)) {
|
||||
if (pCol->colId == PRIMARYKEY_TIMESTAMP_COL_ID && 0 == strcmp(pCol->dbName, pProbeTable->table.dbName) &&
|
||||
0 == strcmp(pCol->tableAlias, pProbeTable->table.tableAlias)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2971,14 +2963,14 @@ static bool isWindowJoinProbeTableCol(SSelectStmt* pSelect, SNode* pNode
|
|||
return false;
|
||||
}
|
||||
|
||||
if (0 == strcmp(pCol->dbName, pProbeTable->table.dbName) && 0 == strcmp(pCol->tableAlias, pProbeTable->table.tableAlias)) {
|
||||
if (0 == strcmp(pCol->dbName, pProbeTable->table.dbName) &&
|
||||
0 == strcmp(pCol->tableAlias, pProbeTable->table.tableAlias)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
typedef struct SCheckColContaisCtx {
|
||||
SNode* pTarget;
|
||||
bool contains;
|
||||
|
@ -3048,7 +3040,6 @@ static bool isWindowJoinSubTbTag(SSelectStmt* pSelect, SNode* pNode) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
static bool isWindowJoinSubTbname(SSelectStmt* pSelect, SNode* pNode) {
|
||||
if (QUERY_NODE_FUNCTION != nodeType(pNode)) {
|
||||
return false;
|
||||
|
@ -3083,7 +3074,8 @@ static bool isWindowJoinSubTbname(SSelectStmt* pSelect, SNode* pNode) {
|
|||
isProbeTable = false;
|
||||
}
|
||||
|
||||
if (!isProbeTable && TSDB_CHILD_TABLE != pTargetTable->pMeta->tableType && TSDB_NORMAL_TABLE != pTargetTable->pMeta->tableType) {
|
||||
if (!isProbeTable && TSDB_CHILD_TABLE != pTargetTable->pMeta->tableType &&
|
||||
TSDB_NORMAL_TABLE != pTargetTable->pMeta->tableType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3157,7 +3149,9 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) {
|
|||
if (pSelect->selectFuncNum > 1 || (isDistinctOrderBy(pCxt) && pCxt->currClause == SQL_CLAUSE_ORDER_BY)) {
|
||||
return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt), ((SExprNode*)(*pNode))->userAlias);
|
||||
}
|
||||
if (isWindowJoinStmt(pSelect) && (isWindowJoinProbeTableCol(pSelect, *pNode) || isWindowJoinGroupCol(pSelect, *pNode) || (isWindowJoinSubTbname(pSelect, *pNode)) || isWindowJoinSubTbTag(pSelect, *pNode))) {
|
||||
if (isWindowJoinStmt(pSelect) &&
|
||||
(isWindowJoinProbeTableCol(pSelect, *pNode) || isWindowJoinGroupCol(pSelect, *pNode) ||
|
||||
(isWindowJoinSubTbname(pSelect, *pNode)) || isWindowJoinSubTbTag(pSelect, *pNode))) {
|
||||
return rewriteExprToGroupKeyFunc(pCxt, pNode);
|
||||
}
|
||||
|
||||
|
@ -3179,7 +3173,8 @@ static int32_t checkExprForGroupBy(STranslateContext* pCxt, SNode** pNode) {
|
|||
}
|
||||
|
||||
static int32_t checkExprListForGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect, SNodeList* pList) {
|
||||
if (NULL == getGroupByList(pCxt) && NULL == pSelect->pWindow && (!isWindowJoinStmt(pSelect) || (!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc))) {
|
||||
if (NULL == getGroupByList(pCxt) && NULL == pSelect->pWindow &&
|
||||
(!isWindowJoinStmt(pSelect) || (!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc))) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
nodesRewriteExprs(pList, doCheckExprForGroupBy, pCxt);
|
||||
|
@ -3249,7 +3244,6 @@ static EDealRes doCheckGetAggColCoexist(SNode** pNode, void* pContext) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
static int32_t checkIsEmptyResult(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (pSelect->timeRange.skey > pSelect->timeRange.ekey && !pSelect->hasCountFunc) {
|
||||
pSelect->isEmptyResult = true;
|
||||
|
@ -3298,7 +3292,8 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
|
|||
}
|
||||
|
||||
static int32_t checkWinJoinAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (!isWindowJoinStmt(pSelect) || (!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc && !pSelect->hasInterpFunc)) {
|
||||
if (!isWindowJoinStmt(pSelect) ||
|
||||
(!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc && !pSelect->hasInterpFunc)) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
if (!pSelect->onlyHasKeepOrderFunc) {
|
||||
|
@ -3309,8 +3304,8 @@ static int32_t checkWinJoinAggColCoexist(STranslateContext* pCxt, SSelectStmt* p
|
|||
if (!pSelect->isDistinct) {
|
||||
nodesRewriteExprs(pSelect->pOrderByList, doCheckGetAggColCoexist, &cxt);
|
||||
}
|
||||
if (((!cxt.existCol && 0 < pSelect->selectFuncNum) || (cxt.existCol && 1 == pSelect->selectFuncNum) )
|
||||
&& !pSelect->hasOtherVectorFunc) {
|
||||
if (((!cxt.existCol && 0 < pSelect->selectFuncNum) || (cxt.existCol && 1 == pSelect->selectFuncNum)) &&
|
||||
!pSelect->hasOtherVectorFunc) {
|
||||
return rewriteColsToSelectValFunc(pCxt, pSelect);
|
||||
}
|
||||
|
||||
|
@ -3318,7 +3313,8 @@ static int32_t checkWinJoinAggColCoexist(STranslateContext* pCxt, SSelectStmt* p
|
|||
bool allProbeTableCols = true;
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, cxt.pColList) {
|
||||
if (isWindowJoinProbeTableCol(pSelect, pNode) || isWindowJoinGroupCol(pSelect, pNode) || (isWindowJoinSubTbname(pSelect, pNode)) || isWindowJoinSubTbTag(pSelect, pNode)) {
|
||||
if (isWindowJoinProbeTableCol(pSelect, pNode) || isWindowJoinGroupCol(pSelect, pNode) ||
|
||||
(isWindowJoinSubTbname(pSelect, pNode)) || isWindowJoinSubTbTag(pSelect, pNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -3335,7 +3331,8 @@ static int32_t checkWinJoinAggColCoexist(STranslateContext* pCxt, SSelectStmt* p
|
|||
|
||||
static int32_t checkHavingGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (NULL == getGroupByList(pCxt) && NULL == pSelect->pPartitionByList && NULL == pSelect->pWindow && !isWindowJoinStmt(pSelect)) {
|
||||
if (NULL == getGroupByList(pCxt) && NULL == pSelect->pPartitionByList && NULL == pSelect->pWindow &&
|
||||
!isWindowJoinStmt(pSelect)) {
|
||||
return code;
|
||||
}
|
||||
if (NULL != pSelect->pHaving) {
|
||||
|
@ -3363,7 +3360,6 @@ static EDealRes searchAggFuncNode(SNode* pNode, void* pContext) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
static int32_t checkWindowGrpFuncCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (NULL != pSelect->pWindow && !pSelect->hasAggFuncs && !pSelect->hasStateKey) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN);
|
||||
|
@ -3688,7 +3684,8 @@ static int32_t replaceTbName(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
return pRewriteCxt.errCode;
|
||||
}
|
||||
|
||||
static int32_t addPrimJoinEqCond(SNode** pCond, SRealTableNode* leftTable, SRealTableNode* rightTable, EJoinType joinType, EJoinSubType subType) {
|
||||
static int32_t addPrimJoinEqCond(SNode** pCond, SRealTableNode* leftTable, SRealTableNode* rightTable,
|
||||
EJoinType joinType, EJoinSubType subType) {
|
||||
struct STableMeta* pLMeta = leftTable->pMeta;
|
||||
struct STableMeta* pRMeta = rightTable->pMeta;
|
||||
|
||||
|
@ -3743,7 +3740,6 @@ static int32_t addPrimJoinEqCond(SNode** pCond, SRealTableNode* leftTable, SReal
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static bool getJoinContais(SNode* pNode) {
|
||||
if (QUERY_NODE_REAL_TABLE == nodeType(pNode)) {
|
||||
return false;
|
||||
|
@ -3804,17 +3800,20 @@ static int32_t checkJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoinTabl
|
|||
|
||||
if (IS_ASOF_JOIN(pJoinTable->subType) || IS_WINDOW_JOIN(pJoinTable->subType)) {
|
||||
if (QUERY_NODE_REAL_TABLE != nodeType(pJoinTable->pLeft) || QUERY_NODE_REAL_TABLE != nodeType(pJoinTable->pRight)) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN, "Only support ASOF/WINDOW join between tables");
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN,
|
||||
"Only support ASOF/WINDOW join between tables");
|
||||
}
|
||||
|
||||
SRealTableNode* pLeft = (SRealTableNode*)pJoinTable->pLeft;
|
||||
if (TSDB_SUPER_TABLE != pLeft->pMeta->tableType && TSDB_CHILD_TABLE != pLeft->pMeta->tableType && TSDB_NORMAL_TABLE != pLeft->pMeta->tableType) {
|
||||
if (TSDB_SUPER_TABLE != pLeft->pMeta->tableType && TSDB_CHILD_TABLE != pLeft->pMeta->tableType &&
|
||||
TSDB_NORMAL_TABLE != pLeft->pMeta->tableType) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN,
|
||||
"Unsupported ASOF/WINDOW join table type");
|
||||
}
|
||||
|
||||
SRealTableNode* pRight = (SRealTableNode*)pJoinTable->pRight;
|
||||
if (TSDB_SUPER_TABLE != pRight->pMeta->tableType && TSDB_CHILD_TABLE != pRight->pMeta->tableType && TSDB_NORMAL_TABLE != pRight->pMeta->tableType) {
|
||||
if (TSDB_SUPER_TABLE != pRight->pMeta->tableType && TSDB_CHILD_TABLE != pRight->pMeta->tableType &&
|
||||
TSDB_NORMAL_TABLE != pRight->pMeta->tableType) {
|
||||
return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SUPPORT_JOIN,
|
||||
"Unsupported ASOF/WINDOW join table type");
|
||||
}
|
||||
|
@ -3849,7 +3848,8 @@ static int32_t checkJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoinTabl
|
|||
}
|
||||
}
|
||||
|
||||
int32_t code = addPrimJoinEqCond(&pJoinTable->addPrimCond, pLeft, pRight, pJoinTable->joinType, pJoinTable->subType);
|
||||
int32_t code =
|
||||
addPrimJoinEqCond(&pJoinTable->addPrimCond, pLeft, pRight, pJoinTable->joinType, pJoinTable->subType);
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
return code;
|
||||
}
|
||||
|
@ -3882,12 +3882,14 @@ static int32_t translateJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoin
|
|||
|
||||
switch (type) {
|
||||
case JOIN_TYPE_INNER:
|
||||
if (*pSType == JOIN_STYPE_OUTER || *pSType == JOIN_STYPE_SEMI || *pSType == JOIN_STYPE_ANTI || *pSType == JOIN_STYPE_ASOF || *pSType == JOIN_STYPE_WIN) {
|
||||
if (*pSType == JOIN_STYPE_OUTER || *pSType == JOIN_STYPE_SEMI || *pSType == JOIN_STYPE_ANTI ||
|
||||
*pSType == JOIN_STYPE_ASOF || *pSType == JOIN_STYPE_WIN) {
|
||||
return buildInvalidOperationMsg(&pCxt->msgBuf, "not supported join type");
|
||||
}
|
||||
break;
|
||||
case JOIN_TYPE_FULL:
|
||||
if (*pSType == JOIN_STYPE_SEMI || *pSType == JOIN_STYPE_ANTI || *pSType == JOIN_STYPE_ASOF || *pSType == JOIN_STYPE_WIN) {
|
||||
if (*pSType == JOIN_STYPE_SEMI || *pSType == JOIN_STYPE_ANTI || *pSType == JOIN_STYPE_ASOF ||
|
||||
*pSType == JOIN_STYPE_WIN) {
|
||||
return buildInvalidOperationMsg(&pCxt->msgBuf, "not supported join type");
|
||||
}
|
||||
// fall down
|
||||
|
@ -3913,7 +3915,8 @@ static int32_t translateJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoin
|
|||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_WIN_OFFSET_UNIT, pEnd->unit);
|
||||
}
|
||||
if (pStart->datum.i > pEnd->datum.i) {
|
||||
TSWAP(((SWindowOffsetNode*)pJoinTable->pWindowOffset)->pStartOffset, ((SWindowOffsetNode*)pJoinTable->pWindowOffset)->pEndOffset);
|
||||
TSWAP(((SWindowOffsetNode*)pJoinTable->pWindowOffset)->pStartOffset,
|
||||
((SWindowOffsetNode*)pJoinTable->pWindowOffset)->pEndOffset);
|
||||
}
|
||||
}
|
||||
} else if (*pSType == JOIN_STYPE_WIN) {
|
||||
|
@ -3922,7 +3925,8 @@ static int32_t translateJoinTable(STranslateContext* pCxt, SJoinTableNode* pJoin
|
|||
|
||||
if (TSDB_CODE_SUCCESS == code && NULL != pJoinTable->pJLimit) {
|
||||
if (*pSType != JOIN_STYPE_ASOF && *pSType != JOIN_STYPE_WIN) {
|
||||
return buildInvalidOperationMsgExt(&pCxt->msgBuf, "JLIMIT not supported for %s join", getFullJoinTypeString(type, *pSType));
|
||||
return buildInvalidOperationMsgExt(&pCxt->msgBuf, "JLIMIT not supported for %s join",
|
||||
getFullJoinTypeString(type, *pSType));
|
||||
}
|
||||
SLimitNode* pJLimit = (SLimitNode*)pJoinTable->pJLimit;
|
||||
if (pJLimit->limit > JOIN_JLIMIT_MAX_VALUE || pJLimit->limit < 0) {
|
||||
|
@ -3950,8 +3954,12 @@ EDealRes joinCondsValidater(SNode* pNode, void* pContext) {
|
|||
if (OP_TYPE_EQUAL < pOp->opType || OP_TYPE_GREATER_THAN > pOp->opType) {
|
||||
break;
|
||||
}
|
||||
if ((QUERY_NODE_COLUMN != nodeType(pOp->pLeft) && QUERY_NODE_FUNCTION != nodeType(pOp->pLeft) && !(QUERY_NODE_OPERATOR == nodeType(pOp->pLeft) && OP_TYPE_JSON_GET_VALUE ==((SOperatorNode*)pOp->pLeft)->opType)) ||
|
||||
(QUERY_NODE_COLUMN != nodeType(pOp->pRight) && QUERY_NODE_FUNCTION != nodeType(pOp->pRight) && !(QUERY_NODE_OPERATOR == nodeType(pOp->pRight) && OP_TYPE_JSON_GET_VALUE ==((SOperatorNode*)pOp->pRight)->opType))){
|
||||
if ((QUERY_NODE_COLUMN != nodeType(pOp->pLeft) && QUERY_NODE_FUNCTION != nodeType(pOp->pLeft) &&
|
||||
!(QUERY_NODE_OPERATOR == nodeType(pOp->pLeft) &&
|
||||
OP_TYPE_JSON_GET_VALUE == ((SOperatorNode*)pOp->pLeft)->opType)) ||
|
||||
(QUERY_NODE_COLUMN != nodeType(pOp->pRight) && QUERY_NODE_FUNCTION != nodeType(pOp->pRight) &&
|
||||
!(QUERY_NODE_OPERATOR == nodeType(pOp->pRight) &&
|
||||
OP_TYPE_JSON_GET_VALUE == ((SOperatorNode*)pOp->pRight)->opType))) {
|
||||
break;
|
||||
}
|
||||
if (QUERY_NODE_COLUMN == nodeType(pOp->pLeft)) {
|
||||
|
@ -3966,7 +3974,8 @@ EDealRes joinCondsValidater(SNode* pNode, void* pContext) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (QUERY_NODE_FUNCTION == nodeType(pOp->pLeft) && FUNCTION_TYPE_TIMETRUNCATE == ((SFunctionNode*)pOp->pLeft)->funcType) {
|
||||
if (QUERY_NODE_FUNCTION == nodeType(pOp->pLeft) &&
|
||||
FUNCTION_TYPE_TIMETRUNCATE == ((SFunctionNode*)pOp->pLeft)->funcType) {
|
||||
SFunctionNode* pFunc = (SFunctionNode*)pOp->pLeft;
|
||||
SNode* pParam = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
if (QUERY_NODE_COLUMN != nodeType(pParam)) {
|
||||
|
@ -3977,7 +3986,8 @@ EDealRes joinCondsValidater(SNode* pNode, void* pContext) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (QUERY_NODE_FUNCTION == nodeType(pOp->pRight) && FUNCTION_TYPE_TIMETRUNCATE == ((SFunctionNode*)pOp->pRight)->funcType) {
|
||||
if (QUERY_NODE_FUNCTION == nodeType(pOp->pRight) &&
|
||||
FUNCTION_TYPE_TIMETRUNCATE == ((SFunctionNode*)pOp->pRight)->funcType) {
|
||||
SFunctionNode* pFunc = (SFunctionNode*)pOp->pRight;
|
||||
SNode* pParam = nodesListGetNode(pFunc->pParameterList, 0);
|
||||
if (QUERY_NODE_COLUMN != nodeType(pParam)) {
|
||||
|
@ -4009,7 +4019,6 @@ int32_t validateJoinConds(STranslateContext* pCxt, SJoinTableNode* pJoinTable) {
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
static int32_t translateAudit(STranslateContext* pCxt, SRealTableNode* pRealTable, SName* pName) {
|
||||
if (pRealTable->pMeta->tableType == TSDB_SUPER_TABLE) {
|
||||
if (IS_AUDIT_DBNAME(pName->dbname) && IS_AUDIT_STB_NAME(pName->tname)) {
|
||||
|
@ -4028,7 +4037,8 @@ static bool isJoinTagEqualOnCond(SNode* pCond, char* leftTableAlias, char* right
|
|||
return false;
|
||||
}
|
||||
SOperatorNode* pOper = (SOperatorNode*)pCond;
|
||||
if (QUERY_NODE_COLUMN != nodeType(pOper->pLeft) || NULL == pOper->pRight || QUERY_NODE_COLUMN != nodeType(pOper->pRight)) {
|
||||
if (QUERY_NODE_COLUMN != nodeType(pOper->pLeft) || NULL == pOper->pRight ||
|
||||
QUERY_NODE_COLUMN != nodeType(pOper->pRight)) {
|
||||
return false;
|
||||
}
|
||||
SColumnNode* pLeft = (SColumnNode*)(pOper->pLeft);
|
||||
|
@ -4085,7 +4095,8 @@ static bool innerJoinTagEqCondContains(SJoinTableNode* pJoinTable, SNode* pWhere
|
|||
SRealTableNode* pRightTable = (SRealTableNode*)pJoinTable->pRight;
|
||||
|
||||
if (NULL != pJoinTable->pOnCond) {
|
||||
condContains = joinTagEqCondContains(pJoinTable->pOnCond, pLeftTable->table.tableAlias, pRightTable->table.tableAlias);
|
||||
condContains =
|
||||
joinTagEqCondContains(pJoinTable->pOnCond, pLeftTable->table.tableAlias, pRightTable->table.tableAlias);
|
||||
}
|
||||
if (NULL != pWhere && !condContains) {
|
||||
condContains = joinTagEqCondContains(pWhere, pLeftTable->table.tableAlias, pRightTable->table.tableAlias);
|
||||
|
@ -4114,7 +4125,8 @@ static bool joinNonPrimColCondContains(SJoinTableNode* pJoinTable) {
|
|||
if (OP_TYPE_EQUAL != pOp->opType) {
|
||||
continue;
|
||||
}
|
||||
if (QUERY_NODE_COLUMN != nodeType(pOp->pLeft) || NULL == pOp->pRight || QUERY_NODE_COLUMN != nodeType(pOp->pRight)) {
|
||||
if (QUERY_NODE_COLUMN != nodeType(pOp->pLeft) || NULL == pOp->pRight ||
|
||||
QUERY_NODE_COLUMN != nodeType(pOp->pRight)) {
|
||||
continue;
|
||||
}
|
||||
if (isPrimaryKeyImpl(pOp->pLeft) || isPrimaryKeyImpl(pOp->pRight)) {
|
||||
|
@ -4131,7 +4143,8 @@ static bool joinNonPrimColCondContains(SJoinTableNode* pJoinTable) {
|
|||
if (OP_TYPE_EQUAL != pOp->opType) {
|
||||
return false;
|
||||
}
|
||||
if (QUERY_NODE_COLUMN != nodeType(pOp->pLeft) || NULL == pOp->pRight || QUERY_NODE_COLUMN != nodeType(pOp->pRight)) {
|
||||
if (QUERY_NODE_COLUMN != nodeType(pOp->pLeft) || NULL == pOp->pRight ||
|
||||
QUERY_NODE_COLUMN != nodeType(pOp->pRight)) {
|
||||
return false;
|
||||
}
|
||||
if (isPrimaryKeyImpl(pOp->pLeft) || isPrimaryKeyImpl(pOp->pRight)) {
|
||||
|
@ -4707,8 +4720,8 @@ static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect
|
|||
}
|
||||
|
||||
static int32_t translateHaving(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||
if (NULL == pSelect->pGroupByList && NULL == pSelect->pPartitionByList && NULL == pSelect->pWindow && !isWindowJoinStmt(pSelect) &&
|
||||
NULL != pSelect->pHaving) {
|
||||
if (NULL == pSelect->pGroupByList && NULL == pSelect->pPartitionByList && NULL == pSelect->pWindow &&
|
||||
!isWindowJoinStmt(pSelect) && NULL != pSelect->pHaving) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION);
|
||||
}
|
||||
if (isWindowJoinStmt(pSelect)) {
|
||||
|
@ -5113,7 +5126,8 @@ static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType == TSDB_SYSTEM_TABLE) {
|
||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED, "WINDOW");
|
||||
}
|
||||
if (QUERY_NODE_INTERVAL_WINDOW != nodeType(pSelect->pWindow) && ((NULL != pSelect->pFromTable && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) &&
|
||||
if (QUERY_NODE_INTERVAL_WINDOW != nodeType(pSelect->pWindow) &&
|
||||
((NULL != pSelect->pFromTable && QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) &&
|
||||
!isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery) &&
|
||||
!isTimeLineAlignedQuery(pCxt->pCurrStmt)) ||
|
||||
(NULL != pSelect->pFromTable && QUERY_NODE_JOIN_TABLE == nodeType(pSelect->pFromTable) &&
|
||||
|
@ -5130,7 +5144,6 @@ static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
|||
return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_NOT_ALLOWED_WIN_QUERY);
|
||||
}
|
||||
|
||||
|
||||
pCxt->currClause = SQL_CLAUSE_WINDOW;
|
||||
int32_t code = translateExpr(pCxt, &pSelect->pWindow);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
|
@ -5652,7 +5665,8 @@ static EDealRes collectTableAlias(SNode* pNode, void* pContext) {
|
|||
*(SSHashObj**)pContext = pHash;
|
||||
}
|
||||
|
||||
tSimpleHashPut(*(SSHashObj**)pContext, pCol->tableAlias, strlen(pCol->tableAlias), pCol->tableAlias, sizeof(pCol->tableAlias));
|
||||
tSimpleHashPut(*(SSHashObj**)pContext, pCol->tableAlias, strlen(pCol->tableAlias), pCol->tableAlias,
|
||||
sizeof(pCol->tableAlias));
|
||||
|
||||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
@ -5779,7 +5793,8 @@ static EDealRes replaceOrderByAliasImpl(SNode** pNode, void* pContext) {
|
|||
FOREACH(pProject, pProjectionList) {
|
||||
SExprNode* pExpr = (SExprNode*)pProject;
|
||||
if (0 == strcmp(((SColumnNode*)*pNode)->colName, pExpr->userAlias)) {
|
||||
if (!pCxt->nameMatch && (nodeType(*pNode) != nodeType(pProject) || (QUERY_NODE_COLUMN == nodeType(pProject) && !nodesEqualNode(*pNode, pProject)))) {
|
||||
if (!pCxt->nameMatch && (nodeType(*pNode) != nodeType(pProject) ||
|
||||
(QUERY_NODE_COLUMN == nodeType(pProject) && !nodesEqualNode(*pNode, pProject)))) {
|
||||
continue;
|
||||
}
|
||||
SNode* pNew = nodesCloneNode(pProject);
|
||||
|
@ -5821,11 +5836,13 @@ static EDealRes replaceOrderByAliasImpl(SNode** pNode, void* pContext) {
|
|||
return DEAL_RES_CONTINUE;
|
||||
}
|
||||
|
||||
static int32_t replaceOrderByAlias(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList, bool checkExists, bool nameMatch) {
|
||||
static int32_t replaceOrderByAlias(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList,
|
||||
bool checkExists, bool nameMatch) {
|
||||
if (NULL == pOrderByList) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
SReplaceOrderByAliasCxt cxt = {.pTranslateCxt = pCxt, .pProjectionList = pProjectionList, .nameMatch = nameMatch, .notFound = false};
|
||||
SReplaceOrderByAliasCxt cxt = {
|
||||
.pTranslateCxt = pCxt, .pProjectionList = pProjectionList, .nameMatch = nameMatch, .notFound = false};
|
||||
nodesRewriteExprsPostOrder(pOrderByList, replaceOrderByAliasImpl, &cxt);
|
||||
if (checkExists && cxt.notFound) {
|
||||
return TSDB_CODE_PAR_ORDERBY_UNKNOWN_EXPR;
|
||||
|
@ -5839,8 +5856,7 @@ static void resetResultTimeline(SSelectStmt* pSelect) {
|
|||
return;
|
||||
}
|
||||
SNode* pOrder = ((SOrderByExprNode*)nodesListGetNode(pSelect->pOrderByList, 0))->pExpr;
|
||||
if ((QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) &&
|
||||
isPrimaryKeyImpl(pOrder)) ||
|
||||
if ((QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) && isPrimaryKeyImpl(pOrder)) ||
|
||||
(QUERY_NODE_TEMP_TABLE != nodeType(pSelect->pFromTable) && isPrimaryKeyImpl(pOrder))) {
|
||||
pSelect->timeLineResMode = TIME_LINE_GLOBAL;
|
||||
} else {
|
||||
|
@ -7029,6 +7045,12 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray, bool calB
|
|||
FOREACH(pNode, pList) {
|
||||
SColumnDefNode* pCol = (SColumnDefNode*)pNode;
|
||||
SFieldWithOptions field = {.type = pCol->dataType.type, .bytes = calcTypeBytes(pCol->dataType)};
|
||||
if (calBytes) {
|
||||
field.bytes = calcTypeBytes(pCol->dataType);
|
||||
} else {
|
||||
field.bytes = pCol->dataType.bytes;
|
||||
}
|
||||
|
||||
strcpy(field.name, pCol->colName);
|
||||
if (pCol->pOptions) {
|
||||
setColEncode(&field.compress, columnEncodeVal(((SColumnOptions*)pCol->pOptions)->encode));
|
||||
|
|
Loading…
Reference in New Issue