fix: having clause issues
This commit is contained in:
parent
623e6e7c2f
commit
997be0a3ed
|
@ -2289,6 +2289,23 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t checkPartitionGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
if (NULL == pSelect->pGroupByList && NULL == pSelect->pPartitionByList && NULL == pSelect->pWindow) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
if (NULL != pSelect->pHaving) {
|
||||||
|
code = checkExprForGroupBy(pCxt, &pSelect->pHaving);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pProjectionList) {
|
||||||
|
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pProjectionList);
|
||||||
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pOrderByList) {
|
||||||
|
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
|
||||||
|
}
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t checkWindowFuncCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
static int32_t checkWindowFuncCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (NULL == pSelect->pWindow) {
|
if (NULL == pSelect->pWindow) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -2901,9 +2918,6 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
pCxt->currClause = SQL_CLAUSE_ORDER_BY;
|
pCxt->currClause = SQL_CLAUSE_ORDER_BY;
|
||||||
code = translateExprList(pCxt, pSelect->pOrderByList);
|
code = translateExprList(pCxt, pSelect->pOrderByList);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
|
|
||||||
}
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3022,9 +3036,6 @@ static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateProjectionList(pCxt, pSelect);
|
code = translateProjectionList(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pProjectionList);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateFillValues(pCxt, pSelect);
|
code = translateFillValues(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
|
@ -3041,9 +3052,6 @@ static int32_t translateHaving(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
}
|
}
|
||||||
pCxt->currClause = SQL_CLAUSE_HAVING;
|
pCxt->currClause = SQL_CLAUSE_HAVING;
|
||||||
int32_t code = translateExpr(pCxt, &pSelect->pHaving);
|
int32_t code = translateExpr(pCxt, &pSelect->pHaving);
|
||||||
if (TSDB_CODE_SUCCESS == code && (NULL != pSelect->pGroupByList || NULL != pSelect->pWindow)) {
|
|
||||||
code = checkExprForGroupBy(pCxt, &pSelect->pHaving);
|
|
||||||
}
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3629,6 +3637,9 @@ static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = translateOrderBy(pCxt, pSelect);
|
code = translateOrderBy(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = checkPartitionGroupBy(pCxt, pSelect);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkAggColCoexist(pCxt, pSelect);
|
code = checkAggColCoexist(pCxt, pSelect);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue