enh: cumulative functions support mixed use

This commit is contained in:
Xiaoyu Wang 2022-07-29 20:41:16 +08:00
parent 41b8ef7d93
commit 32418f161b
4 changed files with 7 additions and 6 deletions

View File

@ -1115,7 +1115,8 @@ static int32_t translateIndefiniteRowsFunc(STranslateContext* pCxt, SFunctionNod
} }
SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt; SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt;
if (pSelect->hasAggFuncs || pSelect->hasMultiRowsFunc || if (pSelect->hasAggFuncs || pSelect->hasMultiRowsFunc ||
(pSelect->hasIndefiniteRowsFunc && pSelect->returnRows != fmGetFuncReturnRows(pFunc))) { (pSelect->hasIndefiniteRowsFunc &&
(FUNC_RETURN_ROWS_INDEFINITE == pSelect->returnRows || pSelect->returnRows != fmGetFuncReturnRows(pFunc)))) {
return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC);
} }
if (NULL != pSelect->pWindow || NULL != pSelect->pGroupByList) { if (NULL != pSelect->pWindow || NULL != pSelect->pGroupByList) {

View File

@ -79,7 +79,7 @@ sql select diff(c7) from $tb
sql_error select diff(c8) from $tb sql_error select diff(c8) from $tb
sql_error select diff(c9) from $tb sql_error select diff(c9) from $tb
sql_error select diff(ts) from $tb sql_error select diff(ts) from $tb
sql_error select diff(c1), diff(c2) from $tb sql select diff(c1), diff(c2) from $tb
sql select 2+diff(c1) from $tb sql select 2+diff(c1) from $tb
sql select diff(c1+2) from $tb sql select diff(c1+2) from $tb

View File

@ -280,7 +280,7 @@ class TDTestCase:
tdSql.error(self.diff_query_form(alias=", min(c1)")) # mix with select function 1 tdSql.error(self.diff_query_form(alias=", min(c1)")) # mix with select function 1
tdSql.error(self.diff_query_form(alias=", top(c1, 5)")) # mix with select function 2 tdSql.error(self.diff_query_form(alias=", top(c1, 5)")) # mix with select function 2
tdSql.error(self.diff_query_form(alias=", spread(c1)")) # mix with calculation function 1 tdSql.error(self.diff_query_form(alias=", spread(c1)")) # mix with calculation function 1
tdSql.error(self.diff_query_form(alias=", diff(c1)")) # mix with calculation function 2 tdSql.query(self.diff_query_form(alias=", diff(c1)")) # mix with calculation function 2
# tdSql.error(self.diff_query_form(alias=" + 2")) # mix with arithmetic 1 # tdSql.error(self.diff_query_form(alias=" + 2")) # mix with arithmetic 1
tdSql.error(self.diff_query_form(alias=" + avg(c1)")) # mix with arithmetic 2 tdSql.error(self.diff_query_form(alias=" + avg(c1)")) # mix with arithmetic 2
tdSql.query(self.diff_query_form(alias=", c2")) # mix with other 1 tdSql.query(self.diff_query_form(alias=", c2")) # mix with other 1

View File

@ -457,15 +457,15 @@ class TDTestCase:
) )
tdSql.execute( tdSql.execute(
f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" f"insert into sub1_bound values ( now()+1s, -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
) )
tdSql.execute( tdSql.execute(
f"insert into sub1_bound values ( now(), 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" f"insert into sub1_bound values ( now()+2s, 2147483643, 9223372036854775803, 32763, 123, 3.39E+38, 1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
) )
tdSql.execute( tdSql.execute(
f"insert into sub1_bound values ( now(), -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )" f"insert into sub1_bound values ( now()+3s, -2147483643, -9223372036854775803, -32763, -123, -3.39E+38, -1.69e+308, True, 'binary_tb1', 'nchar_tb1', now() )"
) )
tdSql.error( tdSql.error(