diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index f1b46aa69b4ce21616e696be702335a579927da4..1ed6dcad395c56406261c6fe21ed0fdb2efc6cf5 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1976,7 +1976,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "leastsquares", .type = FUNCTION_TYPE_LEASTSQUARES, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateLeastSQR, .getEnvFunc = getLeastSQRFuncEnv, .initFunc = leastSQRFunctionSetup, diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 4dff42592a56a5233a3ad6db5dad71a72c0e3e57..b799ae5fb1aa0a3c2602e9139b39cc42610dce05 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -218,7 +218,7 @@ static SNode* createConstantValue() { static int32_t calcConstProjections(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { SNode* pProj = NULL; WHERE_EACH(pProj, pSelect->pProjectionList) { - if (subquery && isUselessCol((SExprNode*)pProj)) { + if (subquery && !pSelect->isDistinct && isUselessCol((SExprNode*)pProj)) { ERASE_NODE(pSelect->pProjectionList); continue; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index da393bb883f6ed32fd425b96dbc7824c4b92df72..ca000fcf2d381d502f55a413d61d3906c802a06f 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -4757,8 +4757,13 @@ static int32_t extractQueryResultSchema(const SNodeList* pProjections, int32_t* int32_t index = 0; FOREACH(pNode, pProjections) { SExprNode* pExpr = (SExprNode*)pNode; - (*pSchema)[index].type = pExpr->resType.type; - (*pSchema)[index].bytes = pExpr->resType.bytes; + if (TSDB_DATA_TYPE_NULL == pExpr->resType.type) { + (*pSchema)[index].type = TSDB_DATA_TYPE_VARCHAR; + (*pSchema)[index].bytes = 0; + } else { + (*pSchema)[index].type = pExpr->resType.type; + (*pSchema)[index].bytes = pExpr->resType.bytes; + } (*pSchema)[index].colId = index + 1; if ('\0' != pExpr->userAlias[0]) { strcpy((*pSchema)[index].name, pExpr->userAlias);