提交 3eb1aaf8 编写于 作者: S shenglian zhou

for agg expr, only support agg1 + agg2 or agg1 + value

上级 f944634f
...@@ -2031,13 +2031,7 @@ static bool willProcessFunctionWithExpr(const tSqlExprItem* pItem) { ...@@ -2031,13 +2031,7 @@ static bool willProcessFunctionWithExpr(const tSqlExprItem* pItem) {
if (TSDB_FUNC_IS_SCALAR(functionId)) { if (TSDB_FUNC_IS_SCALAR(functionId)) {
return true; return true;
} else if (functionId == TSDB_FUNC_SUM ||
functionId == TSDB_FUNC_AVG ||
functionId == TSDB_FUNC_MAX ||
functionId == TSDB_FUNC_MIN) {
return true;
} }
return false; return false;
} }
...@@ -4450,6 +4444,24 @@ static int32_t validateSQLExprTerm(SSqlCmd* pCmd, tSqlExpr* pExpr, ...@@ -4450,6 +4444,24 @@ static int32_t validateSQLExprTerm(SSqlCmd* pCmd, tSqlExpr* pExpr,
return ret; return ret;
} }
{
tSqlExpr* leftChild = pExpr->pLeft;
tSqlExpr* rightChild = pExpr->pRight;
// return invalid operation when one child aggregate and the other child scalar or column
if (leftChild->type == SQL_NODE_SQLFUNCTION && !TSDB_FUNC_IS_SCALAR(leftChild->functionId)) {
if ((rightChild->type == SQL_NODE_SQLFUNCTION && TSDB_FUNC_IS_SCALAR(rightChild->functionId)) ||
rightChild->type == SQL_NODE_TABLE_COLUMN) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
}
if (rightChild->type == SQL_NODE_SQLFUNCTION && !TSDB_FUNC_IS_SCALAR(rightChild->functionId)) {
if ((leftChild->type == SQL_NODE_SQLFUNCTION && TSDB_FUNC_IS_SCALAR(leftChild->functionId)) ||
leftChild->type == SQL_NODE_TABLE_COLUMN) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
}
}
if (uidLeft != uidRight && uidLeft != 0 && uidRight != 0) { if (uidLeft != uidRight && uidLeft != 0 && uidRight != 0) {
return TSDB_CODE_TSC_INVALID_OPERATION; return TSDB_CODE_TSC_INVALID_OPERATION;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册