merge 3.0
This commit is contained in:
parent
d4175cd8f8
commit
ab95a49fa2
|
@ -1236,17 +1236,10 @@ static int32_t rewriteTailOptCreateSort(SIndefRowsFuncLogicNode* pIndef, SLogicN
|
||||||
|
|
||||||
// tail(expr, [limit, offset,] _rowts)
|
// tail(expr, [limit, offset,] _rowts)
|
||||||
SFunctionNode* pTail = (SFunctionNode*)nodesListGetNode(pIndef->pFuncs, 0);
|
SFunctionNode* pTail = (SFunctionNode*)nodesListGetNode(pIndef->pFuncs, 0);
|
||||||
int32_t limitIndex = LIST_LENGTH(pTail->pParameterList) > 2 ? 1 : -1;
|
|
||||||
int32_t offsetIndex = LIST_LENGTH(pTail->pParameterList) > 3 ? 2 : -1;
|
|
||||||
int32_t rowtsIndex = LIST_LENGTH(pTail->pParameterList) - 1;
|
int32_t rowtsIndex = LIST_LENGTH(pTail->pParameterList) - 1;
|
||||||
|
|
||||||
int32_t code = nodesListMakeStrictAppend(
|
int32_t code = nodesListMakeStrictAppend(
|
||||||
&pSort->pSortKeys, rewriteTailOptCreateOrderByExpr(nodesListGetNode(pTail->pParameterList, rowtsIndex)));
|
&pSort->pSortKeys, rewriteTailOptCreateOrderByExpr(nodesListGetNode(pTail->pParameterList, rowtsIndex)));
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
|
||||||
code = rewriteTailOptCreateLimit(limitIndex < 0 ? NULL : nodesListGetNode(pTail->pParameterList, limitIndex),
|
|
||||||
offsetIndex < 0 ? NULL : nodesListGetNode(pTail->pParameterList, offsetIndex),
|
|
||||||
&pSort->node.pLimit);
|
|
||||||
}
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
pSort->node.pTargets = nodesCloneList(((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0))->pTargets);
|
pSort->node.pTargets = nodesCloneList(((SLogicNode*)nodesListGetNode(pSort->node.pChildren, 0))->pTargets);
|
||||||
if (NULL == pSort->node.pTargets) {
|
if (NULL == pSort->node.pTargets) {
|
||||||
|
@ -1281,8 +1274,17 @@ static int32_t rewriteTailOptCreateProject(SIndefRowsFuncLogicNode* pIndef, SLog
|
||||||
TSWAP(pProject->node.pTargets, pIndef->node.pTargets);
|
TSWAP(pProject->node.pTargets, pIndef->node.pTargets);
|
||||||
pProject->node.precision = pIndef->node.precision;
|
pProject->node.precision = pIndef->node.precision;
|
||||||
|
|
||||||
int32_t code = nodesListMakeStrictAppend(
|
// tail(expr, [limit, offset,] _rowts)
|
||||||
&pProject->pProjections, rewriteTailOptCreateProjectExpr((SFunctionNode*)nodesListGetNode(pIndef->pFuncs, 0)));
|
SFunctionNode* pTail = (SFunctionNode*)nodesListGetNode(pIndef->pFuncs, 0);
|
||||||
|
int32_t limitIndex = LIST_LENGTH(pTail->pParameterList) > 2 ? 1 : -1;
|
||||||
|
int32_t offsetIndex = LIST_LENGTH(pTail->pParameterList) > 3 ? 2 : -1;
|
||||||
|
|
||||||
|
int32_t code = nodesListMakeStrictAppend(&pProject->pProjections, rewriteTailOptCreateProjectExpr(pTail));
|
||||||
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
code = rewriteTailOptCreateLimit(limitIndex < 0 ? NULL : nodesListGetNode(pTail->pParameterList, limitIndex),
|
||||||
|
offsetIndex < 0 ? NULL : nodesListGetNode(pTail->pParameterList, offsetIndex),
|
||||||
|
&pProject->node.pLimit);
|
||||||
|
}
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
*pOutput = (SLogicNode*)pProject;
|
*pOutput = (SLogicNode*)pProject;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -188,8 +188,8 @@ class TDTestCase:
|
||||||
|
|
||||||
def check_tail_table(self , tbname , col_name , tail_rows , offset):
|
def check_tail_table(self , tbname , col_name , tail_rows , offset):
|
||||||
tail_sql = f"select tail({col_name} , {tail_rows} , {offset}) from {tbname}"
|
tail_sql = f"select tail({col_name} , {tail_rows} , {offset}) from {tbname}"
|
||||||
equal_sql = f"select {col_name} from (select ts , {col_name} from {tbname} order by ts desc limit {tail_rows} offset {offset}) order by ts"
|
#equal_sql = f"select {col_name} from (select ts , {col_name} from {tbname} order by ts desc limit {tail_rows} offset {offset}) order by ts"
|
||||||
#equal_sql = f"select {col_name} from {tbname} order by ts desc limit {tail_rows} offset {offset}"
|
equal_sql = f"select {col_name} from {tbname} order by ts desc limit {tail_rows} offset {offset}"
|
||||||
tdSql.query(tail_sql)
|
tdSql.query(tail_sql)
|
||||||
tail_result = tdSql.queryResult
|
tail_result = tdSql.queryResult
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue