提交 2c6ffc01 编写于 作者: A Alex Duan

[TS-802]<fix>(query): add parent query have order by case

上级 447c82df
......@@ -1808,11 +1808,17 @@ static bool functionNeedToExecute(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx
}
if (functionId == TSDB_FUNC_FIRST_DST || functionId == TSDB_FUNC_FIRST) {
// if param[2] is set value, input data come from client, order is no relation with pQueryAttr->order , so always return true
if(pCtx->param[2].nType == TSDB_DATA_TYPE_INT)
return true;
return QUERY_IS_ASC_QUERY(pQueryAttr);
}
// denote the order type
if ((functionId == TSDB_FUNC_LAST_DST || functionId == TSDB_FUNC_LAST)) {
// if param[2] is set value, input data come from client, order is no relation with pQueryAttr->order , so always return true
if(pCtx->param[2].nType == TSDB_DATA_TYPE_INT)
return true;
return pCtx->param[0].i64 == pQueryAttr->order.order;
}
......
......@@ -154,7 +154,22 @@ class TDTestCase:
sql = "select last(*) from ( select sum(i1) from st where ts>='2017-07-14 11:40:00' and ts<'2017-07-14 12:40:00' interval(10m) order by ts desc );" # desc
tdSql.waitedQuery(sql, 1, WAITS)
tdSql.checkData(0, 1, 192419100)
# add parent query order by
# first
sql = "select first(*) from (select first(i1) from st interval(10m) order by ts asc) order by ts desc;"
tdSql.waitedQuery(sql, 1, WAITS)
tdSql.checkData(0, 1, 0)
sql = "select first(*) from (select first(i1) from st interval(10m) order by ts desc) order by ts asc;"
tdSql.waitedQuery(sql, 1, WAITS)
tdSql.checkData(0, 1, 0)
# last
sql = "select last(*) from (select first(i1) from st interval(10m) order by ts asc) order by ts desc;"
tdSql.waitedQuery(sql, 1, WAITS)
tdSql.checkData(0, 1, 229400)
sql = "select last(*) from (select first(i1) from st interval(10m) order by ts desc) order by ts asc;"
tdSql.waitedQuery(sql, 1, WAITS)
tdSql.checkData(0, 1, 229400)
#
# add case with filename
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册