feat: reserved aggregate function constant parameters
This commit is contained in:
parent
6e1d926f36
commit
17dd6d6f75
|
@ -132,6 +132,7 @@ typedef enum EOperatorType {
|
||||||
OP_TYPE_MOD,
|
OP_TYPE_MOD,
|
||||||
// unary arithmetic operator
|
// unary arithmetic operator
|
||||||
OP_TYPE_MINUS,
|
OP_TYPE_MINUS,
|
||||||
|
OP_TYPE_ASSIGN,
|
||||||
|
|
||||||
// bit operator
|
// bit operator
|
||||||
OP_TYPE_BIT_AND,
|
OP_TYPE_BIT_AND,
|
||||||
|
|
|
@ -624,16 +624,36 @@ static EDealRes collectAndRewrite(SRewritePrecalcExprsCxt* pCxt, SNode** pNode)
|
||||||
return DEAL_RES_IGNORE_CHILD;
|
return DEAL_RES_IGNORE_CHILD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t rewriteValueToOperator(SRewritePrecalcExprsCxt* pCxt, SNode** pNode) {
|
||||||
|
SOperatorNode* pOper = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR);
|
||||||
|
if (NULL == pOper) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
SValueNode* pVal = (SValueNode*)*pNode;
|
||||||
|
pOper->node.resType = pVal->node.resType;
|
||||||
|
strcpy(pOper->node.aliasName, pVal->node.aliasName);
|
||||||
|
pOper->opType = OP_TYPE_ASSIGN;
|
||||||
|
pOper->pLeft = *pNode;
|
||||||
|
*pNode = (SNode*)pOper;
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
static EDealRes doRewritePrecalcExprs(SNode** pNode, void* pContext) {
|
static EDealRes doRewritePrecalcExprs(SNode** pNode, void* pContext) {
|
||||||
SRewritePrecalcExprsCxt* pCxt = (SRewritePrecalcExprsCxt*)pContext;
|
SRewritePrecalcExprsCxt* pCxt = (SRewritePrecalcExprsCxt*)pContext;
|
||||||
switch (nodeType(*pNode)) {
|
switch (nodeType(*pNode)) {
|
||||||
|
case QUERY_NODE_VALUE: {
|
||||||
|
if (TSDB_CODE_SUCCESS != rewriteValueToOperator(pCxt, pNode)) {
|
||||||
|
return DEAL_RES_ERROR;
|
||||||
|
}
|
||||||
|
return collectAndRewrite(pCxt, pNode);
|
||||||
|
}
|
||||||
case QUERY_NODE_OPERATOR:
|
case QUERY_NODE_OPERATOR:
|
||||||
case QUERY_NODE_LOGIC_CONDITION: {
|
case QUERY_NODE_LOGIC_CONDITION: {
|
||||||
return collectAndRewrite(pContext, pNode);
|
return collectAndRewrite(pCxt, pNode);
|
||||||
}
|
}
|
||||||
case QUERY_NODE_FUNCTION: {
|
case QUERY_NODE_FUNCTION: {
|
||||||
if (fmIsScalarFunc(((SFunctionNode*)(*pNode))->funcId)) {
|
if (fmIsScalarFunc(((SFunctionNode*)(*pNode))->funcId)) {
|
||||||
return collectAndRewrite(pContext, pNode);
|
return collectAndRewrite(pCxt, pNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -49,6 +49,8 @@ TEST_F(PlanGroupByTest, aggFunc) {
|
||||||
run("SELECT LAST(*), FIRST(*) FROM t1");
|
run("SELECT LAST(*), FIRST(*) FROM t1");
|
||||||
|
|
||||||
run("SELECT LAST(*), FIRST(*) FROM t1 GROUP BY c1");
|
run("SELECT LAST(*), FIRST(*) FROM t1 GROUP BY c1");
|
||||||
|
|
||||||
|
run("SELECT SUM(10), COUNT(c1) FROM t1 GROUP BY c2");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PlanGroupByTest, selectFunc) {
|
TEST_F(PlanGroupByTest, selectFunc) {
|
||||||
|
|
Loading…
Reference in New Issue