diff --git a/docs/en/12-taos-sql/10-function.md b/docs/en/12-taos-sql/10-function.md index ad6d5d77fb..234625bfb4 100644 --- a/docs/en/12-taos-sql/10-function.md +++ b/docs/en/12-taos-sql/10-function.md @@ -698,7 +698,7 @@ ELAPSED(ts_primary_key [, time_unit]) LEASTSQUARES(expr, start_val, step_val) ``` -**Description**: The linear regression function of the specified column and the timestamp column (primary key), `start_val` is the initial value and `step_val` is the step value. +**Description**: The linear regression function of a specified column, `start_val` is the initial value and `step_val` is the step value. **Return value type**: A string in the format of "(slope, intercept)" diff --git a/docs/zh/12-taos-sql/10-function.md b/docs/zh/12-taos-sql/10-function.md index 773ea67989..3c0ee06caf 100644 --- a/docs/zh/12-taos-sql/10-function.md +++ b/docs/zh/12-taos-sql/10-function.md @@ -700,7 +700,7 @@ ELAPSED(ts_primary_key [, time_unit]) LEASTSQUARES(expr, start_val, step_val) ``` -**功能说明**:统计表中某列的值是主键(时间戳)的拟合直线方程。start_val 是自变量初始值,step_val 是自变量的步长值。 +**功能说明**:统计表中某列的值的拟合直线方程。start_val 是自变量初始值,step_val 是自变量的步长值。 **返回数据类型**:字符串表达式(斜率, 截距)。 diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 844bfb07fc..cee4000155 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -2350,7 +2350,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "leastsquares", .type = FUNCTION_TYPE_LEASTSQUARES, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC, .translateFunc = translateLeastSQR, .getEnvFunc = getLeastSQRFuncEnv, .initFunc = leastSQRFunctionSetup, @@ -2916,8 +2916,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "tail", .type = FUNCTION_TYPE_TAIL, - .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | - FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, + .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateTail, .getEnvFunc = getTailFuncEnv, .initFunc = tailFunctionSetup, @@ -2928,8 +2927,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "unique", .type = FUNCTION_TYPE_UNIQUE, - .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_TIMELINE_FUNC | - FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, + .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, .translateFunc = translateUnique, .getEnvFunc = getUniqueFuncEnv, .initFunc = uniqueFunctionSetup, diff --git a/tests/system-test/2-query/leastsquares.py b/tests/system-test/2-query/leastsquares.py index 1718802a82..3dfd1f6aca 100644 --- a/tests/system-test/2-query/leastsquares.py +++ b/tests/system-test/2-query/leastsquares.py @@ -219,15 +219,20 @@ class TDTestCase: tdSql.checkRows(1) res = tdSql.getData(0, 0) if res is None: - tdLog.exit("result is not correct") + tdLog.exit("result is not correct") - def __test_current(self): + def __test_current(self, dbname=DBNAME): # tdSql.query("explain select c1 from {dbname}.ct1") # tdSql.query("explain select 1 from {dbname}.ct2") # tdSql.query("explain select cast(ceil(c6) as bigint) from {dbname}.ct4 group by c6") # tdSql.query("explain select count(c3) from {dbname}.ct4 group by c7 having count(c3) > 0") # tdSql.query("explain select ct2.c3 from {dbname}.ct4 join ct2 on ct4.ts=ct2.ts") # tdSql.query("explain select c1 from stb1 where c1 is not null and c1 in (0, 1, 2) or c1 between 2 and 100 ") + # + tdSql.query(f"select leastsquares(c1, 1, 1) from (select c1 from {dbname}.nt1 group by c1)") + tdSql.query(f"select leastsquares(c1, 1, 1) from (select c1 from {dbname}.nt1 partition by c1)") + tdSql.query(f"select leastsquares(c1, 1, 1) from (select c1 from {dbname}.nt1 order by c1)") + tdSql.query(f"select leastsquares(c1, 1, 1) from (select c1 from {dbname}.nt1 union select c1 from {dbname}.nt1)") self.leastsquares_check() diff --git a/tests/system-test/2-query/tail.py b/tests/system-test/2-query/tail.py index 43321810d0..99791db3df 100644 --- a/tests/system-test/2-query/tail.py +++ b/tests/system-test/2-query/tail.py @@ -412,6 +412,18 @@ class TDTestCase: tdSql.checkData(0,0,4) tdSql.checkData(1,0,1) + tdSql.query(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 group by c2);") + tdSql.checkRows(1) + + tdSql.query(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 partition by c2);") + tdSql.checkRows(1) + + tdSql.query(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 order by c2);") + tdSql.checkRows(1) + + tdSql.query(f"select tail(a, 1) from (select _rowts, first(c2) as a from {dbname}.ct1 union select _rowts, first(c2) as a from {dbname}.ct1);") + tdSql.checkRows(1) + def check_boundary_values(self, dbname="bound_test"): tdSql.execute(f"drop database if exists {dbname}") diff --git a/tests/system-test/2-query/unique.py b/tests/system-test/2-query/unique.py index 9b5da50e1f..b3053817d3 100644 --- a/tests/system-test/2-query/unique.py +++ b/tests/system-test/2-query/unique.py @@ -438,6 +438,15 @@ class TDTestCase: tdSql.checkData(0,0,4) tdSql.checkData(1,0,1) + tdSql.query(f"select unique(c1) v from (select _rowts, c1 from {dbname}.ct1 partition by c2)") + tdSql.checkRows(10) + + tdSql.query(f"select unique(c1) v from (select _rowts, c1 from {dbname}.ct1 order by c2)") + tdSql.checkRows(10) + + tdSql.query(f"select unique(c1) v from (select _rowts, c1 from {dbname}.ct1 union all select _rowts, c1 from {dbname}.ct1)") + tdSql.checkRows(10) + # TD-19911 tdSql.error("select unique(mode(12)) from (select _rowts , t1 , tbname from db.stb1 );") tdSql.error("select unique(mode(t1,1)) from (select _rowts , t1 , tbname from db.stb1 );")