Merge pull request #22365 from taosdata/enh/TD-25366
enh: remove timeline dependence of certain functions
This commit is contained in:
commit
1f3eacba17
|
@ -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)"
|
||||
|
||||
|
|
|
@ -700,7 +700,7 @@ ELAPSED(ts_primary_key [, time_unit])
|
|||
LEASTSQUARES(expr, start_val, step_val)
|
||||
```
|
||||
|
||||
**功能说明**:统计表中某列的值是主键(时间戳)的拟合直线方程。start_val 是自变量初始值,step_val 是自变量的步长值。
|
||||
**功能说明**:统计表中某列的值的拟合直线方程。start_val 是自变量初始值,step_val 是自变量的步长值。
|
||||
|
||||
**返回数据类型**:字符串表达式(斜率, 截距)。
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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}")
|
||||
|
|
|
@ -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 );")
|
||||
|
|
Loading…
Reference in New Issue