From 7e553f7bc905943441fe91a9b0b788d5a1942ed4 Mon Sep 17 00:00:00 2001 From: factosea <285808407@qq.com> Date: Thu, 23 Jan 2025 19:27:32 +0800 Subject: [PATCH] fxi: use the same agg func outside of cols --- source/libs/nodes/src/nodesEqualFuncs.c | 7 ++-- tests/system-test/2-query/cols_function.py | 37 ++++++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/source/libs/nodes/src/nodesEqualFuncs.c b/source/libs/nodes/src/nodesEqualFuncs.c index 501a9fe17d..d255c2fd6b 100644 --- a/source/libs/nodes/src/nodesEqualFuncs.c +++ b/source/libs/nodes/src/nodesEqualFuncs.c @@ -139,10 +139,13 @@ static bool functionNodeEqual(const SFunctionNode* a, const SFunctionNode* b) { COMPARE_STRING_FIELD(functionName); COMPARE_NODE_LIST_FIELD(pParameterList); if (a->funcType == FUNCTION_TYPE_SELECT_VALUE) { - if ((a->node.bindTupleFuncIdx != b->node.bindTupleFuncIdx) && - (a->node.bindTupleFuncIdx != 0 || b->node.bindTupleFuncIdx != 0)) + if ((a->node.bindTupleFuncIdx != b->node.bindTupleFuncIdx)) return false; + } else { + if ((a->node.tupleFuncIdx != b->node.tupleFuncIdx)) { return false; + } } + return true; } diff --git a/tests/system-test/2-query/cols_function.py b/tests/system-test/2-query/cols_function.py index 54dea9b4e5..86cf2528e3 100644 --- a/tests/system-test/2-query/cols_function.py +++ b/tests/system-test/2-query/cols_function.py @@ -471,8 +471,41 @@ class TDTestCase: tdSql.checkData(1, 3, 2) tdSql.checkData(1, 4, 4) - # todo 1 , has same select function outof cols func - #select cols(last_row(c0), ts as t1, c1 as c11), cols(first(c0), ts as t2, c1 c21), first(c0) from test.meters where c0 < 4; + # fixed: has same select function outof cols func + tdSql.query(f'select cols(last_row(c0), ts as t1, c1 as c11), cols(first(c0), ts as t2, c1 c21), first(c0) from test.meters where c0 < 4 group by tbname order by t1') + tdSql.checkResColNameList(['t1', 'c11', 't2', 'c21', 'first(c0)']) + tdSql.checkRows(2) + tdSql.checkCols(5) + tdSql.checkData(0, 0, 1734574929000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1734574929000) + tdSql.checkData(0, 3, 1) + tdSql.checkData(0, 4, 1) + tdSql.checkData(1, 0, 1734574929003) + tdSql.checkData(1, 1, 3) + tdSql.checkData(1, 2, 1734574929000) + tdSql.checkData(1, 3, 1) + tdSql.checkData(1, 4, 1) + + tdSql.query(f'select cols(last_row(c0), ts as t1, c1 as c11), cols(first(c0), ts as t2, c1 c21), first(c0), cols(last(c0), ts, c1) from test.meters where c0 < 4 group by tbname order by t1;') + tdSql.checkResColNameList(['t1', 'c11', 't2', 'c21', 'first(c0)', 'ts', 'c1']) + tdSql.checkRows(2) + tdSql.checkCols(7) + tdSql.checkData(0, 0, 1734574929000) + tdSql.checkData(0, 1, 1) + tdSql.checkData(0, 2, 1734574929000) + tdSql.checkData(0, 3, 1) + tdSql.checkData(0, 4, 1) + tdSql.checkData(0, 5, 1734574929000) + tdSql.checkData(0, 6, 1) + tdSql.checkData(1, 0, 1734574929003) + tdSql.checkData(1, 1, 3) + tdSql.checkData(1, 2, 1734574929000) + tdSql.checkData(1, 3, 1) + tdSql.checkData(1, 4, 1) + tdSql.checkData(1, 5, 1734574929003) + tdSql.checkData(1, 6, 3) + # todo 2, sub query has cols func # select * from (select cols(last_row(c0), ts as t1, c1 as c11), cols(first(c0), ts as t2, c1 c21), first(c0) from test.meters where c0 < 4); # todo 3, cols on system table