diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 7a7f19c3af..e04488a68c 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -158,6 +158,7 @@ extern int32_t tsMetaCacheMaxSize; extern int32_t tsSlowLogThreshold; extern int32_t tsSlowLogScope; extern int32_t tsTimeSeriesThreshold; +extern bool tsMultiResultFunctionStarReturnTags; // client extern int32_t tsMinSlidingTime; diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 3381d52050..dae86f1a32 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -170,6 +170,7 @@ int32_t tsMetaCacheMaxSize = -1; // MB int32_t tsSlowLogThreshold = 3; // seconds int32_t tsSlowLogScope = SLOW_LOG_TYPE_ALL; int32_t tsTimeSeriesThreshold = 50; +bool tsMultiResultFunctionStarReturnTags = false; /* * denote if the server needs to compress response message at the application layer to client, including query rsp, @@ -545,6 +546,8 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, CFG_SCOPE_BOTH, CFG_DYN_BOTH) != 0) return -1; if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) return -1; + + if (cfgAddBool(pCfg, "multiResultFunctionStarReturnTags", tsMultiResultFunctionStarReturnTags, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0) return -1; return 0; } @@ -1103,6 +1106,8 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tsKeepAliveIdle = cfgGetItem(pCfg, "keepAliveIdle")->i32; tsExperimental = cfgGetItem(pCfg, "experimental")->bval; + + tsMultiResultFunctionStarReturnTags = cfgGetItem(pCfg, "multiResultFunctionStarReturnTags")->bval; return 0; } @@ -1742,7 +1747,8 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, char *name) { {"shellActivityTimer", &tsShellActivityTimer}, {"slowLogThreshold", &tsSlowLogThreshold}, {"useAdapter", &tsUseAdapter}, - {"experimental", &tsExperimental}}; + {"experimental", &tsExperimental}, + {"multiResultFunctionStarReturnTags", &tsMultiResultFunctionStarReturnTags} }; if (taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true) != 0) { taosCfgSetOption(options, tListLen(options), pItem, false); diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 1ea0ec8574..778c9b1590 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, false, &pExprs); + code = createAllColumns(pCxt, !tsMultiResultFunctionStarReturnTags, &pExprs); } else if (nodesIsTableStar(pPara)) { - code = createTableAllCols(pCxt, (SColumnNode*)pPara, false, &pExprs); + code = createTableAllCols(pCxt, (SColumnNode*)pPara, !tsMultiResultFunctionStarReturnTags, &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 8d02f817e3..533f59f4b2 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 $data03 != @tm0@ then +if $data02 != @tm0@ then return -1 endi @@ -310,7 +310,7 @@ if $data11 != 421 then return -1 endi -if $data13 != @tm1@ then +if $data12 != @tm1@ then return -1 endi diff --git a/tests/script/tsim/parser/join_multitables.sim b/tests/script/tsim/parser/join_multitables.sim index 59e41bc9d9..d2f8ea4a88 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 $data[0][10] != @21-03-01 01:00:00.000@ then +if $data05 != @21-03-01 01:00:00.000@ then return -1 endi -if $data[0][11] != 9911 then +if $data06 != 9911 then return -1 endi -if $data[0][12] != 9911.000000000 then +if $data07 != 9911.000000000 then return -1 endi -if $data[0][13] != 11 then +if $data08 != 11 then return -1 endi @@ -837,16 +837,16 @@ endi if $data04 != 05 then return -1 endi -if $data[0][10] != @21-03-01 05:00:00.000@ then +if $data05 != @21-03-01 05:00:00.000@ then return -1 endi -if $data[0][11] != 9915 then +if $data06 != 9915 then return -1 endi -if $data[0][12] != 9915.000000000 then +if $data07 != 9915.000000000 then return -1 endi -if $data[0][13] != 15 then +if $data08 != 15 then return -1 endi diff --git a/tests/script/tsim/parser/last_both_query.sim b/tests/script/tsim/parser/last_both_query.sim index 1cfb2a316f..5f86412199 100644 --- a/tests/script/tsim/parser/last_both_query.sim +++ b/tests/script/tsim/parser/last_both_query.sim @@ -243,11 +243,11 @@ endi if $data04 != @70-01-01 07:59:57.000@ then return -1 endi -if $data06 != @21-05-12 10:10:12.000@ then +if $data05 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi -if $data07 != @70-01-01 07:59:57.000@ then +if $data06 != @70-01-01 07:59:57.000@ 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 7bf6a51731..30196e0b62 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 $data06 != @21-05-12 10:10:12.000@ then +if $data05 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi -if $data07 != @70-01-01 07:59:57.000@ then +if $data06 != @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 278de7ab49..33267e3cfd 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 $data03 != @19-01-01 01:01:01.000@ then +if $data02 != @19-01-01 01:01:01.000@ then return -1 endi -if $data04 != @abc@ then +if $data03 != @abc@ then return -1 endi -if $data05 != 123.981000000 then +if $data04 != 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 1d71d6a68e..6bd6938678 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 != 7 then +if $cols != 4 then return -1 endi -if $data06 != tba2 then +if $data03 != tba2 then return -1 endi sql select last_row(*) from db1.sta; -if $cols != 7 then +if $cols != 4 then return -1 endi -if $data06 != tba2 then +if $data03 != tba2 then return -1 endi sql select first(*) from db1.sta; -if $cols != 7 then +if $cols != 4 then return -1 endi -if $data06 != tba1 then +if $data03 != tba1 then return -1 endi @@ -71,29 +71,29 @@ if $data06 != tba1 then endi sql select last(b.*) from db1.sta b; -if $cols != 7 then +if $cols != 4 then return -1 endi -if $data06 != tba2 then +if $data03 != tba2 then return -1 endi sql select last_row(b.*) from db1.sta b; -if $cols != 7 then +if $cols != 4 then return -1 endi -if $data06 != tba2 then +if $data03 != tba2 then return -1 endi sql select first(b.*) from db1.sta b; -if $cols != 7 then +if $cols != 4 then return -1 endi -if $data06 != tba1 then +if $data03 != tba1 then return -1 endi diff --git a/tests/script/tsim/query/cache_last.sim b/tests/script/tsim/query/cache_last.sim index f936f822a5..65eb46de69 100644 --- a/tests/script/tsim/query/cache_last.sim +++ b/tests/script/tsim/query/cache_last.sim @@ -35,12 +35,11 @@ if $data03 != b then return -1 endi sql explain select count(*), last(*) from sta; -if $data00 != @-> Merge (columns=5 width=230 input_order=unknown output_order=unknown mode=column)@ then - print $data00 +if $data00 != @-> Merge (columns=4 width=226 input_order=unknown output_order=unknown mode=column)@ then return -1 endi sql explain select first(f1), last(*) from sta; -if $data00 != @-> Merge (columns=5 width=230 input_order=unknown output_order=unknown mode=column)@ then +if $data00 != @-> Merge (columns=4 width=226 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 cd572b05cb..b04b3a75f3 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, 3, last_ts4) - tdSql.checkData(0, 4, 4 * maxRange + 1) + tdSql.checkData(0, 2, last_ts4) + tdSql.checkData(0, 3, 4 * maxRange + 1) explain_res = self.explain_sql(sql) self.check_explain_res_no_row("Last Row Scan", explain_res, sql) @@ -302,8 +302,8 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, last_ts4) tdSql.checkData(0, 1, 5 * maxRange - 1) - tdSql.checkData(0, 3, last_ts4) - tdSql.checkData(0, 4, 4 * maxRange + 1) + tdSql.checkData(0, 2, last_ts4) + tdSql.checkData(0, 3, 4 * maxRange + 1) explain_res = self.explain_sql(sql) self.check_explain_res_has_row("Last Row Scan", explain_res, sql) @@ -453,8 +453,8 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, last_ts4) tdSql.checkData(0, 1, 5 * maxRange - 1) - tdSql.checkData(0, 3, last_ts4) - tdSql.checkData(0, 4, 4 * maxRange + 1) + tdSql.checkData(0, 2, last_ts4) + tdSql.checkData(0, 3, 4 * maxRange + 1) explain_res = self.explain_sql(sql) self.check_explain_res_has_row("Last Row Scan", explain_res, sql) @@ -587,7 +587,7 @@ class TDTestCase: explain_res = self.explain_sql(sql) self.check_explain_res_has_row("Last Row Scan", explain_res, sql) - self.check_explain_res_has_row("Table Scan", explain_res, sql) + self.check_explain_res_no_row("Table Scan", explain_res, sql) sql = f'select last_row(ts), last(ts), last_row(id), last(id) from last_test_both_model.st;' tdSql.query(sql) @@ -607,7 +607,7 @@ class TDTestCase: tdSql.checkData(0, 0, last_ts4) tdSql.checkData(0, 1, 5 * maxRange - 1) #tdSql.checkData(0, 2, last_ts4) - tdSql.checkData(0, 4, 4 * maxRange + 1) + tdSql.checkData(0, 3, 4 * maxRange + 1) explain_res = self.explain_sql(sql) self.check_explain_res_has_row("Last Row Scan", explain_res, sql)