fix: a problem of super table order by
This commit is contained in:
parent
2df98609e8
commit
52bbbe59d2
|
@ -285,7 +285,7 @@ class MockCatalogServiceImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
void createSmaIndex(const SMCreateSmaReq* pReq) {
|
void createSmaIndex(const SMCreateSmaReq* pReq) {
|
||||||
STableIndexInfo info;
|
STableIndexInfo info = {0};
|
||||||
info.intervalUnit = pReq->intervalUnit;
|
info.intervalUnit = pReq->intervalUnit;
|
||||||
info.slidingUnit = pReq->slidingUnit;
|
info.slidingUnit = pReq->slidingUnit;
|
||||||
info.interval = pReq->interval;
|
info.interval = pReq->interval;
|
||||||
|
|
|
@ -537,10 +537,12 @@ static int32_t stbSplCreateMergeKeys(SNodeList* pSortKeys, SNodeList* pTargets,
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pSortKeys) {
|
FOREACH(pNode, pSortKeys) {
|
||||||
SOrderByExprNode* pSortKey = (SOrderByExprNode*)pNode;
|
SOrderByExprNode* pSortKey = (SOrderByExprNode*)pNode;
|
||||||
|
SExprNode* pSortExpr = (SExprNode*)pSortKey->pExpr;
|
||||||
SNode* pTarget = NULL;
|
SNode* pTarget = NULL;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
FOREACH(pTarget, pTargets) {
|
FOREACH(pTarget, pTargets) {
|
||||||
if (0 == strcmp(((SExprNode*)pSortKey->pExpr)->aliasName, ((SColumnNode*)pTarget)->colName)) {
|
if ((QUERY_NODE_COLUMN == nodeType(pSortExpr) && nodesEqualNode((SNode*)pSortExpr, pTarget)) ||
|
||||||
|
(0 == strcmp(pSortExpr->aliasName, ((SColumnNode*)pTarget)->colName))) {
|
||||||
code = nodesListMakeStrictAppend(&pMergeKeys, stbSplCreateOrderByExpr(pSortKey, pTarget));
|
code = nodesListMakeStrictAppend(&pMergeKeys, stbSplCreateOrderByExpr(pSortKey, pTarget));
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
break;
|
break;
|
||||||
|
@ -549,7 +551,7 @@ static int32_t stbSplCreateMergeKeys(SNodeList* pSortKeys, SNodeList* pTargets,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code && !found) {
|
if (TSDB_CODE_SUCCESS == code && !found) {
|
||||||
SNode* pCol = stbSplCreateColumnNode((SExprNode*)pSortKey->pExpr);
|
SNode* pCol = stbSplCreateColumnNode(pSortExpr);
|
||||||
code = nodesListMakeStrictAppend(&pMergeKeys, stbSplCreateOrderByExpr(pSortKey, pCol));
|
code = nodesListMakeStrictAppend(&pMergeKeys, stbSplCreateOrderByExpr(pSortKey, pCol));
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
code = nodesListStrictAppend(pTargets, pCol);
|
code = nodesListStrictAppend(pTargets, pCol);
|
||||||
|
|
|
@ -28,6 +28,8 @@ TEST_F(PlanOrderByTest, basic) {
|
||||||
// ORDER BY key is not in the projection list
|
// ORDER BY key is not in the projection list
|
||||||
run("SELECT c1 FROM t1 ORDER BY c2");
|
run("SELECT c1 FROM t1 ORDER BY c2");
|
||||||
|
|
||||||
|
run("SELECT c1 AS a FROM t1 ORDER BY a");
|
||||||
|
|
||||||
run("SELECT c1 + 10 AS a FROM t1 ORDER BY a");
|
run("SELECT c1 + 10 AS a FROM t1 ORDER BY a");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,4 +61,6 @@ TEST_F(PlanOrderByTest, stable) {
|
||||||
run("SELECT c2 FROM st1 ORDER BY c1");
|
run("SELECT c2 FROM st1 ORDER BY c1");
|
||||||
|
|
||||||
run("SELECT c2 FROM st1 PARTITION BY c2 ORDER BY c1");
|
run("SELECT c2 FROM st1 PARTITION BY c2 ORDER BY c1");
|
||||||
|
|
||||||
|
run("SELECT c1 AS a FROM st1 ORDER BY a");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue