group const value func
This commit is contained in:
parent
b72792e20e
commit
2a675ccf6b
|
@ -138,7 +138,7 @@ typedef enum EFunctionType {
|
||||||
FUNCTION_TYPE_CACHE_LAST_ROW,
|
FUNCTION_TYPE_CACHE_LAST_ROW,
|
||||||
FUNCTION_TYPE_CACHE_LAST,
|
FUNCTION_TYPE_CACHE_LAST,
|
||||||
FUNCTION_TYPE_TABLE_COUNT,
|
FUNCTION_TYPE_TABLE_COUNT,
|
||||||
FUNCTION_TYPE_SELECT_TAG,
|
FUNCTION_TYPE_GROUP_CONST_VALUE,
|
||||||
|
|
||||||
// distributed splitting functions
|
// distributed splitting functions
|
||||||
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
|
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
|
||||||
|
@ -257,7 +257,7 @@ bool fmIsConstantResFunc(SFunctionNode* pFunc);
|
||||||
bool fmIsSkipScanCheckFunc(int32_t funcId);
|
bool fmIsSkipScanCheckFunc(int32_t funcId);
|
||||||
bool fmIsPrimaryKeyFunc(int32_t funcId);
|
bool fmIsPrimaryKeyFunc(int32_t funcId);
|
||||||
bool fmIsProcessByRowFunc(int32_t funcId);
|
bool fmIsProcessByRowFunc(int32_t funcId);
|
||||||
bool fmIsSelectTagFunc(int32_t funcId);
|
bool fmisSelectGroupConstValueFunc(int32_t funcId);
|
||||||
|
|
||||||
void getLastCacheDataType(SDataType* pType, int32_t pkBytes);
|
void getLastCacheDataType(SDataType* pType, int32_t pkBytes);
|
||||||
SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList);
|
SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList);
|
||||||
|
|
|
@ -604,7 +604,7 @@ void copyResultrowToDataBlock(SExprInfo* pExprInfo, int32_t numOfExprs, SResultR
|
||||||
pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
|
pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
|
||||||
if (pCtx[j].fpSet.finalize) {
|
if (pCtx[j].fpSet.finalize) {
|
||||||
if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_key") == 0 ||
|
if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_key") == 0 ||
|
||||||
strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_tag") == 0) {
|
strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_group_const_value") == 0) {
|
||||||
// for groupkey along with functions that output multiple lines(e.g. Histogram)
|
// for groupkey along with functions that output multiple lines(e.g. Histogram)
|
||||||
// need to match groupkey result for each output row of that function.
|
// need to match groupkey result for each output row of that function.
|
||||||
if (pCtx[j].resultInfo->numOfRes != 0) {
|
if (pCtx[j].resultInfo->numOfRes != 0) {
|
||||||
|
|
|
@ -233,9 +233,9 @@ static bool isGroupKeyFunc(SExprInfo* pExprInfo) {
|
||||||
return (functionType == FUNCTION_TYPE_GROUP_KEY);
|
return (functionType == FUNCTION_TYPE_GROUP_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isSelectTagFunc(SExprInfo* pExprInfo) {
|
static bool isSelectGroupConstValueFunc(SExprInfo* pExprInfo) {
|
||||||
int32_t functionType = pExprInfo->pExpr->_function.functionType;
|
int32_t functionType = pExprInfo->pExpr->_function.functionType;
|
||||||
return (functionType == FUNCTION_TYPE_SELECT_TAG);
|
return (functionType == FUNCTION_TYPE_GROUP_CONST_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool getIgoreNullRes(SExprSupp* pExprSup) {
|
static bool getIgoreNullRes(SExprSupp* pExprSup) {
|
||||||
|
@ -301,7 +301,7 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
||||||
colDataSetVal(pDst, pResBlock->info.rows, (char*)&isFilled, false);
|
colDataSetVal(pDst, pResBlock->info.rows, (char*)&isFilled, false);
|
||||||
continue;
|
continue;
|
||||||
} else if (!isInterpFunc(pExprInfo)) {
|
} else if (!isInterpFunc(pExprInfo)) {
|
||||||
if (isGroupKeyFunc(pExprInfo) || isSelectTagFunc(pExprInfo)) {
|
if (isGroupKeyFunc(pExprInfo) || isSelectGroupConstValueFunc(pExprInfo)) {
|
||||||
if (pSrcBlock != NULL) {
|
if (pSrcBlock != NULL) {
|
||||||
int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId;
|
int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId;
|
||||||
SColumnInfoData* pSrc = taosArrayGet(pSrcBlock->pDataBlock, srcSlot);
|
SColumnInfoData* pSrc = taosArrayGet(pSrcBlock->pDataBlock, srcSlot);
|
||||||
|
@ -313,7 +313,7 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
|
||||||
|
|
||||||
char* v = colDataGetData(pSrc, index);
|
char* v = colDataGetData(pSrc, index);
|
||||||
colDataSetVal(pDst, pResBlock->info.rows, v, false);
|
colDataSetVal(pDst, pResBlock->info.rows, v, false);
|
||||||
} else if(!isSelectTagFunc(pExprInfo)){
|
} else if(!isSelectGroupConstValueFunc(pExprInfo)){
|
||||||
// use stored group key
|
// use stored group key
|
||||||
SGroupKeys* pkey = pSliceInfo->pPrevGroupKey;
|
SGroupKeys* pkey = pSliceInfo->pPrevGroupKey;
|
||||||
if (pkey->isNull == false) {
|
if (pkey->isNull == false) {
|
||||||
|
|
|
@ -254,6 +254,8 @@ bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv);
|
||||||
int32_t groupKeyFunction(SqlFunctionCtx* pCtx);
|
int32_t groupKeyFunction(SqlFunctionCtx* pCtx);
|
||||||
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||||
|
int32_t groupConstValueFunction(SqlFunctionCtx* pCtx);
|
||||||
|
int32_t groupConstValueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -4109,14 +4109,14 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.finalizeFunc = NULL
|
.finalizeFunc = NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = "_select_tag",
|
.name = "_group_const_value",
|
||||||
.type = FUNCTION_TYPE_SELECT_TAG,
|
.type = FUNCTION_TYPE_GROUP_CONST_VALUE,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_KEEP_ORDER_FUNC,
|
||||||
.translateFunc = translateGroupKey,
|
.translateFunc = translateSelectValue,
|
||||||
.getEnvFunc = getGroupKeyFuncEnv,
|
.getEnvFunc = getSelectivityFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = groupKeyFunction,
|
.processFunc = groupConstValueFunction,
|
||||||
.finalizeFunc = groupKeyFinalize,
|
.finalizeFunc = groupConstValueFinalize,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
|
@ -6615,7 +6615,7 @@ int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
return pResInfo->numOfRes;
|
return pResInfo->numOfRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
|
int32_t groupConstValueFunction(SqlFunctionCtx* pCtx) {
|
||||||
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx);
|
||||||
SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
SGroupKeyInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
|
||||||
|
|
||||||
|
@ -6626,13 +6626,13 @@ int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
|
||||||
// escape rest of data blocks to avoid first entry to be overwritten.
|
// escape rest of data blocks to avoid first entry to be overwritten.
|
||||||
if (pInfo->hasResult) {
|
if (pInfo->hasResult) {
|
||||||
goto _group_key_over;
|
goto _group_value_over;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pInputCol->pData == NULL || colDataIsNull_s(pInputCol, startIndex)) {
|
if (pInputCol->pData == NULL || colDataIsNull_s(pInputCol, startIndex)) {
|
||||||
pInfo->isNull = true;
|
pInfo->isNull = true;
|
||||||
pInfo->hasResult = true;
|
pInfo->hasResult = true;
|
||||||
goto _group_key_over;
|
goto _group_value_over;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* data = colDataGetData(pInputCol, startIndex);
|
char* data = colDataGetData(pInputCol, startIndex);
|
||||||
|
@ -6644,13 +6644,17 @@ int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
|
||||||
}
|
}
|
||||||
pInfo->hasResult = true;
|
pInfo->hasResult = true;
|
||||||
|
|
||||||
_group_key_over:
|
_group_value_over:
|
||||||
|
|
||||||
SET_VAL(pResInfo, 1, 1);
|
SET_VAL(pResInfo, 1, 1);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
int32_t groupKeyFunction(SqlFunctionCtx* pCtx) {
|
||||||
|
return groupConstValueFunction(pCtx);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t groupConstValueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
int32_t slotId = pCtx->pExpr->base.resSchema.slotId;
|
||||||
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId);
|
||||||
|
|
||||||
|
@ -6670,6 +6674,10 @@ int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
|
||||||
return pResInfo->numOfRes;
|
return pResInfo->numOfRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock){
|
||||||
|
return groupConstValueFinalize(pCtx, pBlock);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) {
|
||||||
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
|
SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx);
|
||||||
SGroupKeyInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo);
|
SGroupKeyInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo);
|
||||||
|
|
|
@ -268,11 +268,11 @@ bool fmIsGroupKeyFunc(int32_t funcId) {
|
||||||
return FUNCTION_TYPE_GROUP_KEY == funcMgtBuiltins[funcId].type;
|
return FUNCTION_TYPE_GROUP_KEY == funcMgtBuiltins[funcId].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fmIsSelectTagFunc(int32_t funcId) {
|
bool fmisSelectGroupConstValueFunc(int32_t funcId) {
|
||||||
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
if (funcId < 0 || funcId >= funcMgtBuiltinsNum) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return FUNCTION_TYPE_SELECT_TAG == funcMgtBuiltins[funcId].type;
|
return FUNCTION_TYPE_GROUP_CONST_VALUE == funcMgtBuiltins[funcId].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fmIsBlockDistFunc(int32_t funcId) {
|
bool fmIsBlockDistFunc(int32_t funcId) {
|
||||||
|
|
|
@ -3169,7 +3169,7 @@ static EDealRes rewriteExprToSelectTagFunc(STranslateContext* pCxt, SNode** pNod
|
||||||
return DEAL_RES_ERROR;
|
return DEAL_RES_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(pFunc->functionName, "_select_tag");
|
strcpy(pFunc->functionName, "_group_const_value");
|
||||||
strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName);
|
strcpy(pFunc->node.aliasName, ((SExprNode*)*pNode)->aliasName);
|
||||||
strcpy(pFunc->node.userAlias, ((SExprNode*)*pNode)->userAlias);
|
strcpy(pFunc->node.userAlias, ((SExprNode*)*pNode)->userAlias);
|
||||||
pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode);
|
pCxt->errCode = nodesListMakeAppend(&pFunc->pParameterList, *pNode);
|
||||||
|
@ -4974,7 +4974,7 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
|
|
||||||
static EDealRes needFillImpl(SNode* pNode, void* pContext) {
|
static EDealRes needFillImpl(SNode* pNode, void* pContext) {
|
||||||
if ((isAggFunc(pNode) || isInterpFunc(pNode)) && FUNCTION_TYPE_GROUP_KEY != ((SFunctionNode*)pNode)->funcType
|
if ((isAggFunc(pNode) || isInterpFunc(pNode)) && FUNCTION_TYPE_GROUP_KEY != ((SFunctionNode*)pNode)->funcType
|
||||||
&& FUNCTION_TYPE_SELECT_TAG != ((SFunctionNode*)pNode)->funcType) {
|
&& FUNCTION_TYPE_GROUP_CONST_VALUE != ((SFunctionNode*)pNode)->funcType) {
|
||||||
*(bool*)pContext = true;
|
*(bool*)pContext = true;
|
||||||
return DEAL_RES_END;
|
return DEAL_RES_END;
|
||||||
}
|
}
|
||||||
|
|
|
@ -891,7 +891,7 @@ static int32_t createIndefRowsFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isInterpFunc(int32_t funcId) {
|
static bool isInterpFunc(int32_t funcId) {
|
||||||
return fmIsInterpFunc(funcId) || fmIsInterpPseudoColumnFunc(funcId) || fmIsGroupKeyFunc(funcId) || fmIsSelectTagFunc(funcId);
|
return fmIsInterpFunc(funcId) || fmIsInterpPseudoColumnFunc(funcId) || fmIsGroupKeyFunc(funcId) || fmisSelectGroupConstValueFunc(funcId);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
static int32_t createInterpFuncLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) {
|
||||||
|
|
Loading…
Reference in New Issue