From 9a8d03f0ca34fefc0562a8c60ffa9d47a4d21c43 Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao> Date: Tue, 2 Apr 2024 14:03:02 +0800 Subject: [PATCH] adj last function --- source/libs/parser/src/parTranslater.c | 4 ++-- tests/script/tsim/parser/first_last_query.sim | 4 ++-- tests/script/tsim/parser/join_multitables.sim | 16 ++++++------- tests/script/tsim/parser/last_cache_query.sim | 4 ++-- tests/script/tsim/parser/lastrow2.sim | 6 ++--- tests/script/tsim/query/bi_star_table.sim | 24 +++++++++---------- tests/script/tsim/query/cache_last.sim | 5 ++-- .../system-test/2-query/last_and_last_row.py | 4 ++-- 8 files changed, 34 insertions(+), 33 deletions(-) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 2110013310..1ea0ec8574 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -3368,9 +3368,9 @@ static int32_t createMultiResFuncsParas(STranslateContext* pCxt, SNodeList* pSrc SNode* pPara = NULL; FOREACH(pPara, pSrcParas) { if (nodesIsStar(pPara)) { - code = createAllColumns(pCxt, true, &pExprs); + code = createAllColumns(pCxt, false, &pExprs); } else if (nodesIsTableStar(pPara)) { - code = createTableAllCols(pCxt, (SColumnNode*)pPara, true, &pExprs); + code = createTableAllCols(pCxt, (SColumnNode*)pPara, false, &pExprs); } else { code = nodesListMakeStrictAppend(&pExprs, nodesCloneNode(pPara)); } diff --git a/tests/script/tsim/parser/first_last_query.sim b/tests/script/tsim/parser/first_last_query.sim index 533f59f4b2..8d02f817e3 100644 --- a/tests/script/tsim/parser/first_last_query.sim +++ b/tests/script/tsim/parser/first_last_query.sim @@ -298,7 +298,7 @@ if $data01 != 112 then return -1 endi -if $data02 != @tm0@ then +if $data03 != @tm0@ then return -1 endi @@ -310,7 +310,7 @@ if $data11 != 421 then return -1 endi -if $data12 != @tm1@ then +if $data13 != @tm1@ then return -1 endi diff --git a/tests/script/tsim/parser/join_multitables.sim b/tests/script/tsim/parser/join_multitables.sim index d2f8ea4a88..59e41bc9d9 100644 --- a/tests/script/tsim/parser/join_multitables.sim +++ b/tests/script/tsim/parser/join_multitables.sim @@ -805,16 +805,16 @@ endi if $data04 != 01 then return -1 endi -if $data05 != @21-03-01 01:00:00.000@ then +if $data[0][10] != @21-03-01 01:00:00.000@ then return -1 endi -if $data06 != 9911 then +if $data[0][11] != 9911 then return -1 endi -if $data07 != 9911.000000000 then +if $data[0][12] != 9911.000000000 then return -1 endi -if $data08 != 11 then +if $data[0][13] != 11 then return -1 endi @@ -837,16 +837,16 @@ endi if $data04 != 05 then return -1 endi -if $data05 != @21-03-01 05:00:00.000@ then +if $data[0][10] != @21-03-01 05:00:00.000@ then return -1 endi -if $data06 != 9915 then +if $data[0][11] != 9915 then return -1 endi -if $data07 != 9915.000000000 then +if $data[0][12] != 9915.000000000 then return -1 endi -if $data08 != 15 then +if $data[0][13] != 15 then return -1 endi diff --git a/tests/script/tsim/parser/last_cache_query.sim b/tests/script/tsim/parser/last_cache_query.sim index 30196e0b62..7bf6a51731 100644 --- a/tests/script/tsim/parser/last_cache_query.sim +++ b/tests/script/tsim/parser/last_cache_query.sim @@ -243,11 +243,11 @@ endi if $data04 != @70-01-01 07:59:57.000@ then return -1 endi -if $data05 != @21-05-12 10:10:12.000@ then +if $data06 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi -if $data06 != @70-01-01 07:59:57.000@ then +if $data07 != @70-01-01 07:59:57.000@ then return -1 endi diff --git a/tests/script/tsim/parser/lastrow2.sim b/tests/script/tsim/parser/lastrow2.sim index 33267e3cfd..278de7ab49 100644 --- a/tests/script/tsim/parser/lastrow2.sim +++ b/tests/script/tsim/parser/lastrow2.sim @@ -54,13 +54,13 @@ sql select last_row(*), ts, 'abc', 123.981, tbname from m1 if $rows != 1 then return -1 endi -if $data02 != @19-01-01 01:01:01.000@ then +if $data03 != @19-01-01 01:01:01.000@ then return -1 endi -if $data03 != @abc@ then +if $data04 != @abc@ then return -1 endi -if $data04 != 123.981000000 then +if $data05 != 123.981000000 then print expect 123.981000000, actual: $data04 return -1 endi diff --git a/tests/script/tsim/query/bi_star_table.sim b/tests/script/tsim/query/bi_star_table.sim index 6bd6938678..1d71d6a68e 100644 --- a/tests/script/tsim/query/bi_star_table.sim +++ b/tests/script/tsim/query/bi_star_table.sim @@ -33,29 +33,29 @@ if $data06 != tba1 then endi sql select last(*) from db1.sta; -if $cols != 4 then +if $cols != 7 then return -1 endi -if $data03 != tba2 then +if $data06 != tba2 then return -1 endi sql select last_row(*) from db1.sta; -if $cols != 4 then +if $cols != 7 then return -1 endi -if $data03 != tba2 then +if $data06 != tba2 then return -1 endi sql select first(*) from db1.sta; -if $cols != 4 then +if $cols != 7 then return -1 endi -if $data03 != tba1 then +if $data06 != tba1 then return -1 endi @@ -71,29 +71,29 @@ if $data06 != tba1 then endi sql select last(b.*) from db1.sta b; -if $cols != 4 then +if $cols != 7 then return -1 endi -if $data03 != tba2 then +if $data06 != tba2 then return -1 endi sql select last_row(b.*) from db1.sta b; -if $cols != 4 then +if $cols != 7 then return -1 endi -if $data03 != tba2 then +if $data06 != tba2 then return -1 endi sql select first(b.*) from db1.sta b; -if $cols != 4 then +if $cols != 7 then return -1 endi -if $data03 != tba1 then +if $data06 != tba1 then return -1 endi diff --git a/tests/script/tsim/query/cache_last.sim b/tests/script/tsim/query/cache_last.sim index 65eb46de69..f936f822a5 100644 --- a/tests/script/tsim/query/cache_last.sim +++ b/tests/script/tsim/query/cache_last.sim @@ -35,11 +35,12 @@ if $data03 != b then return -1 endi sql explain select count(*), last(*) from sta; -if $data00 != @-> Merge (columns=4 width=226 input_order=unknown output_order=unknown mode=column)@ then +if $data00 != @-> Merge (columns=5 width=230 input_order=unknown output_order=unknown mode=column)@ then + print $data00 return -1 endi sql explain select first(f1), last(*) from sta; -if $data00 != @-> Merge (columns=4 width=226 input_order=unknown output_order=unknown mode=column)@ then +if $data00 != @-> Merge (columns=5 width=230 input_order=unknown output_order=unknown mode=column)@ then return -1 endi sql select first(f1), last(*) from sta; diff --git a/tests/system-test/2-query/last_and_last_row.py b/tests/system-test/2-query/last_and_last_row.py index b04b3a75f3..ce25c3dd99 100644 --- a/tests/system-test/2-query/last_and_last_row.py +++ b/tests/system-test/2-query/last_and_last_row.py @@ -152,8 +152,8 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, last_ts4) tdSql.checkData(0, 1, 5 * maxRange - 1) - tdSql.checkData(0, 2, last_ts4) - tdSql.checkData(0, 3, 4 * maxRange + 1) + tdSql.checkData(0, 3, last_ts4) + tdSql.checkData(0, 4, 4 * maxRange + 1) explain_res = self.explain_sql(sql) self.check_explain_res_no_row("Last Row Scan", explain_res, sql)