delete unused code
This commit is contained in:
parent
c277abd3bf
commit
0d56695d96
|
@ -3448,30 +3448,6 @@ static int32_t getPositionValue(const SValueNode* pVal) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t checkOrderByAggForGroupBy(STranslateContext* pCxt, SSelectStmt* pSelect, SNodeList* pOrderByList) {
|
|
||||||
if (NULL != getGroupByList(pCxt) || NULL != pSelect->pWindow) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
SNode* pProject = NULL;
|
|
||||||
FOREACH(pProject, pSelect->pProjectionList) {
|
|
||||||
if(isAggFunc(pProject)) {
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SNode* pNode = NULL;
|
|
||||||
WHERE_EACH(pNode, pOrderByList) {
|
|
||||||
SNode* pExpr = ((SOrderByExprNode*)pNode)->pExpr;
|
|
||||||
if ((QUERY_NODE_FUNCTION == nodeType(pExpr))) {
|
|
||||||
SFunctionNode* pFunc = (SFunctionNode*)pExpr;
|
|
||||||
if (fmIsAggFunc(pFunc->funcId)) {
|
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_SINGLE_GROUP);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
WHERE_NEXT;
|
|
||||||
}
|
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList,
|
static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList,
|
||||||
bool* pOther) {
|
bool* pOther) {
|
||||||
*pOther = false;
|
*pOther = false;
|
||||||
|
@ -3490,15 +3466,7 @@ static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pPro
|
||||||
} else if (0 == pos || pos > LIST_LENGTH(pProjectionList)) {
|
} else if (0 == pos || pos > LIST_LENGTH(pProjectionList)) {
|
||||||
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT);
|
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT);
|
||||||
} else {
|
} else {
|
||||||
// SColumnRefNode* pCol = (SColumnRefNode*)nodesMakeNode(QUERY_NODE_COLUMN_REF);
|
// No longer using SColumnRefNode, processing in replaceOrderByAliasImpl function
|
||||||
// if (NULL == pCol) {
|
|
||||||
// return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY);
|
|
||||||
// }
|
|
||||||
// strcpy(pCol->colName, ((SExprNode*)nodesListGetNode(pProjectionList, pos - 1))->aliasName);
|
|
||||||
|
|
||||||
// (SExprNode*)nodesListGetNode(pProjectionList, pos - 1);
|
|
||||||
// ((SOrderByExprNode*)pNode)->pExpr = (SNode*)pCol;
|
|
||||||
// nodesDestroyNode(pExpr);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*pOther = true;
|
*pOther = true;
|
||||||
|
@ -3525,9 +3493,6 @@ static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) {
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
|
code = checkExprListForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
|
||||||
}
|
}
|
||||||
if (other && TSDB_CODE_SUCCESS == code) {
|
|
||||||
// code = checkOrderByAggForGroupBy(pCxt, pSelect, pSelect->pOrderByList);
|
|
||||||
}
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -507,7 +507,7 @@ class TDTestCase:
|
||||||
tdSql.query(f"select last(*), last_row(*),last(c1), last_row(c1) from {dbname}.stb1 ")
|
tdSql.query(f"select last(*), last_row(*),last(c1), last_row(c1) from {dbname}.stb1 ")
|
||||||
tdSql.query(f"select last(*), last_row(*),last(c1), last_row(c1) from {dbname}.ct1 ")
|
tdSql.query(f"select last(*), last_row(*),last(c1), last_row(c1) from {dbname}.ct1 ")
|
||||||
tdSql.query(f"select last(*), last_row(*),last(c1+1)*max(c1), last_row(c1+2)/2 from {dbname}.t1 ")
|
tdSql.query(f"select last(*), last_row(*),last(c1+1)*max(c1), last_row(c1+2)/2 from {dbname}.t1 ")
|
||||||
# tdSql.query(f"select last_row(*) ,abs(c1/2)+100 from {dbname}.stb1 where tbname =\"ct1\" ")
|
tdSql.query(f"select last_row(*) ,abs(c1/2)+100 from {dbname}.stb1 where tbname =\"ct1\" ")
|
||||||
tdSql.query(f"select c1, last_row(c5) from {dbname}.ct1 ")
|
tdSql.query(f"select c1, last_row(c5) from {dbname}.ct1 ")
|
||||||
tdSql.error(f"select c1, last_row(c5) ,last(c1) from {dbname}.stb1 ")
|
tdSql.error(f"select c1, last_row(c5) ,last(c1) from {dbname}.stb1 ")
|
||||||
|
|
||||||
|
|
|
@ -278,11 +278,30 @@ class TDTestCase:
|
||||||
|
|
||||||
def queryOrderByAgg(self):
|
def queryOrderByAgg(self):
|
||||||
|
|
||||||
|
tdSql.query("SELECT COUNT(*) FROM t1 order by COUNT(*)")
|
||||||
|
|
||||||
|
tdSql.query("SELECT COUNT(*) FROM t1 order by last(c2)")
|
||||||
|
|
||||||
|
tdSql.query("SELECT c1 FROM t1 order by last(ts)")
|
||||||
|
|
||||||
|
tdSql.query("SELECT ts FROM t1 order by last(ts)")
|
||||||
|
|
||||||
|
tdSql.query("SELECT last(ts), ts, c1 FROM t1 order by 2")
|
||||||
|
|
||||||
|
tdSql.query("SELECT ts, last(ts) FROM t1 order by last(ts)")
|
||||||
|
|
||||||
tdSql.query(f"SELECT * FROM t1 order by last(ts)")
|
tdSql.query(f"SELECT * FROM t1 order by last(ts)")
|
||||||
|
|
||||||
tdSql.query(f"SELECT last(ts) FROM t1 order by last(ts)")
|
tdSql.query(f"SELECT last(ts) as t2, ts FROM t1 order by 1")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
tdSql.query(f"SELECT last(ts), ts FROM t1 order by last(ts)")
|
tdSql.query(f"SELECT last(ts), ts FROM t1 order by last(ts)")
|
||||||
|
tdSql.checkRows(1)
|
||||||
|
|
||||||
|
tdSql.error(f"SELECT first(ts), ts FROM t1 order by last(ts)")
|
||||||
|
|
||||||
|
tdSql.error(f"SELECT last(ts) as t2, ts FROM t1 order by last(t2)")
|
||||||
|
|
||||||
|
|
||||||
# run
|
# run
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|
Loading…
Reference in New Issue