From 6d5d6746f256712d297d3084ca6449496604499d Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 19 Jul 2022 18:51:06 +0800 Subject: [PATCH] feat: sql command 'show tags from table_name' --- source/libs/function/src/builtins.c | 2 +- source/libs/function/src/builtinsimpl.c | 3 ++- source/libs/parser/src/parTranslater.c | 3 +++ source/libs/scalar/src/filter.c | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 5c10330f9c..066c4ad145 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1034,7 +1034,7 @@ static int32_t translateHistogramImpl(SFunctionNode* pFunc, char* pErrBuf, int32 // param1 ~ param3 if (((SExprNode*)nodesListGetNode(pFunc->pParameterList, 1))->resType.type != TSDB_DATA_TYPE_BINARY || ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 2))->resType.type != TSDB_DATA_TYPE_BINARY || - ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type != TSDB_DATA_TYPE_BIGINT) { + !IS_INTEGER_TYPE(((SExprNode*)nodesListGetNode(pFunc->pParameterList, 3))->resType.type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 61157e55d0..fc99a646ca 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -2380,7 +2380,8 @@ int32_t percentileFunction(SqlFunctionCtx* pCtx) { int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SVariant* pVal = &pCtx->param[1].param; - double v = (pVal->nType == TSDB_DATA_TYPE_BIGINT) ? pVal->i : pVal->d; + double v = + (IS_SIGNED_NUMERIC_TYPE(pVal->nType) ? pVal->i : (IS_UNSIGNED_NUMERIC_TYPE(pVal->nType) ? pVal->u : pVal->d)); SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SPercentileInfo* ppInfo = (SPercentileInfo*)GET_ROWCELL_INTERBUF(pResInfo); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index c6613b1412..3d840a9374 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -936,6 +936,9 @@ static EDealRes translateValueImpl(STranslateContext* pCxt, SValueNode* pVal, SD pVal->node.resType = targetDt; pVal->node.resType.scale = pVal->unit; pVal->translate = true; + if (!strict && TSDB_DATA_TYPE_UBIGINT == pVal->node.resType.type && pVal->datum.u <= INT64_MAX) { + pVal->node.resType.type = TSDB_DATA_TYPE_BIGINT; + } return res; } diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 0348f13191..41ca72dc7b 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -3682,6 +3682,10 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { if (OP_TYPE_IN != node->opType) { SColumnNode *refNode = (SColumnNode *)node->pLeft; SValueNode *valueNode = (SValueNode *)node->pRight; + if (FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP) + && TSDB_DATA_TYPE_UBIGINT == valueNode->node.resType.type && valueNode->datum.u <= INT64_MAX) { + valueNode->node.resType.type = TSDB_DATA_TYPE_BIGINT; + } int32_t type = vectorGetConvertType(refNode->node.resType.type, valueNode->node.resType.type); if (0 != type && type != refNode->node.resType.type) { stat->scalarMode = true;