- Notifications
You must be signed in to change notification settings - Fork5k
test: add test case#33759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:3.0
Are you sure you want to change the base?
test: add test case#33759
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4644,9 +4644,9 @@ static EDealRes searchAggFuncNode(SNode* pNode, void* pContext) { | ||
| } | ||
| static int32_t checkWindowGrpFuncCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) { | ||
| //if (NULL != pSelect->pWindow && !pSelect->hasAggFuncs && !pSelect->hasStateKey) { | ||
| // return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN); | ||
| //} | ||
Comment on lines +4647 to +4649 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||
| if (isWindowJoinStmt(pSelect)) { | ||
| if (!pSelect->hasAggFuncs && NULL != pSelect->pHaving) { | ||
| return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_WJOIN_HAVING_EXPR); | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -49,6 +49,8 @@ def test_interval(self): | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdStream.dropAllStreamsAndDbs() | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.ComputeInterval1() | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdStream.dropAllStreamsAndDbs() | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.WithoutAggInterval() | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdStream.dropAllStreamsAndDbs() | ||||||||||||||||||||||||||||||||||||||||||||||||
| def QueryInterval(self): | ||||||||||||||||||||||||||||||||||||||||||||||||
| dbPrefix = "m_in_db" | ||||||||||||||||||||||||||||||||||||||||||||||||
| @@ -1535,3 +1537,83 @@ def ComputeInterval1(self): | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.checkRows(1) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.checkData(0, 1, 1) | ||||||||||||||||||||||||||||||||||||||||||||||||
| def WithoutAggInterval(self): | ||||||||||||||||||||||||||||||||||||||||||||||||
| dbPrefix = "m_in_db" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tbPrefix = "m_in_tb" | ||||||||||||||||||||||||||||||||||||||||||||||||
| mtPrefix = "m_in_mt" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tbNum = 10 | ||||||||||||||||||||||||||||||||||||||||||||||||
| rowNum = 20 | ||||||||||||||||||||||||||||||||||||||||||||||||
| totalNum = 200 | ||||||||||||||||||||||||||||||||||||||||||||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdLog.info(f"=============== step1") | ||||||||||||||||||||||||||||||||||||||||||||||||
| i = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| db = dbPrefix + str(i) | ||||||||||||||||||||||||||||||||||||||||||||||||
| mt = mtPrefix + str(i) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.prepare(db, drop=True) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.execute(f"use {db}") | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.execute(f"create table {mt} (ts timestamp, tbcol int) TAGS(tgcol int)") | ||||||||||||||||||||||||||||||||||||||||||||||||
| i = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| while i < tbNum: | ||||||||||||||||||||||||||||||||||||||||||||||||
| tb = tbPrefix + str(i) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.execute(f"create table {tb} using {mt} tags( {i} )") | ||||||||||||||||||||||||||||||||||||||||||||||||
| x = 0 | ||||||||||||||||||||||||||||||||||||||||||||||||
| while x < rowNum: | ||||||||||||||||||||||||||||||||||||||||||||||||
| cc = x * 60000 | ||||||||||||||||||||||||||||||||||||||||||||||||
| ms = 1601481600000 + cc | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.execute(f"insert into {tb} values ({ms} , {x} )") | ||||||||||||||||||||||||||||||||||||||||||||||||
| x = x + 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| i = i + 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines +1558 to +1571 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. For better readability and to follow Python best practices, these Suggested change
| ||||||||||||||||||||||||||||||||||||||||||||||||
| tdLog.info(f"=============== step2") | ||||||||||||||||||||||||||||||||||||||||||||||||
| i = 1 | ||||||||||||||||||||||||||||||||||||||||||||||||
| tb = tbPrefix + str(i) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, 1, count(tbcol) from m_in_tb1 interval(1m)" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.query(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.checkRows(20) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, 1 from m_in_tb1 interval(1m)" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.query(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.checkRows(20) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, 1, count(tbcol) from m_in_tb1 interval(5m)" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.query(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.checkRows(4) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, 1 from m_in_tb1 interval(5m)" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.query(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.checkRows(4) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, 1, tgcol, count(tbcol) from m_in_tb1 interval(5m)" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.error(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, 1, tgcol from m_in_tb1 interval(5m)" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.error(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, 1, tgcol, count(tbcol) from m_in_mt0 partition by tbname interval(5m)" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.query(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.checkRows(40) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, 1, tgcol from m_in_mt0 partition by tbname interval(5m)" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.query(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.checkRows(40) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, 1, tgcol, count(tbcol) from m_in_mt0 partition by tbname interval(5m);" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.query(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.checkRows(40) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, _wend, tbname, 1, tgcol, count(tbcol) from m_in_mt0 partition by tbname interval(5m);" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.query(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.checkRows(40) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, tbcol, tbname, 1, tgcol, count(tbcol) from m_in_mt0 partition by tbname interval(5m);" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.error(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
| sql = "select _wstart, ts, tbname, 1, tgcol, count(tbcol) from m_in_mt0 partition by tbname interval(5m);" | ||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.error(sql) | ||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines +1607 to +1619 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -230,6 +230,7 @@ def test_state_window(self): | ||
| self.check_crash_for_state_window3() | ||
| self.check_crash_for_state_window4() | ||
| self.check_crash_for_state_window5() | ||
| self.test_state_window_start_with_null() | ||
| #tdSql.close() | ||
| tdLog.success(f"{__file__} successfully executed") | ||
| @@ -254,6 +255,7 @@ def test_state_window_start_with_null(self): | ||
| """ | ||
| tdLog.info("test state window start with null start") | ||
| tdSql.execute("drop database if exists testdb") | ||
| tdSql.execute("create database if not exists testdb keep 3650", show=True) | ||
| tdSql.execute("use testdb") | ||
| @@ -330,5 +332,28 @@ def test_state_window_start_with_null(self): | ||
| tdSql.checkData(3, 8, "2025-09-01 10:00:13.000") | ||
| tdSql.checkData(3, 9, "2025-09-01 10:00:13.000") | ||
| tdSql.checkData(3, 10, "b") | ||
| sql = "select _wstart, _wduration, _wend, s from ntb state_window(s, 2)" | ||
| tdSql.query(sql, show=True) | ||
| tdSql.checkRows(4) | ||
| tdSql.checkData(0, 0, "2025-09-01 10:00:00.000") | ||
| tdSql.checkData(0, 1, 4000) | ||
| tdSql.checkData(0, 2, "2025-09-01 10:00:04.000") | ||
| tdSql.checkData(0, 3, "a") | ||
| tdSql.checkData(1, 0, "2025-09-01 10:00:04.001") | ||
| tdSql.checkData(1, 1, 3999) | ||
| tdSql.checkData(1, 2, "2025-09-01 10:00:08.000") | ||
| tdSql.checkData(1, 3, "b") | ||
| tdSql.checkData(2, 0, "2025-09-01 10:00:08.001") | ||
| tdSql.checkData(2, 1, 1999) | ||
| tdSql.checkData(2, 2, "2025-09-01 10:00:10.000") | ||
| tdSql.checkData(2, 3, "a") | ||
| tdSql.checkData(3, 0, "2025-09-01 10:00:10.001") | ||
| tdSql.checkData(3, 1, 2999) | ||
| tdSql.checkData(3, 2, "2025-09-01 10:00:13.000") | ||
| tdSql.checkData(3, 3, "b") | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||
| sql = "select _wstart, _wduration, _wend, v from ntb state_window(s, 2)" | ||
| tdSql.error(sql, show=True) | ||
| event = threading.Event() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -278,3 +278,15 @@ def test_event(self): | ||
| ) | ||
| tdSql.checkRows(4) | ||
| tdLog.info(f"======rows={tdSql.getRows()})") | ||
| sql = "select _wstart, tbname from st partition by tbname event_window start with a > 0 end with b = 2 slimit 2 limit 2;" | ||
| tdSql.query(sql) | ||
| tdSql.checkRows(4) | ||
| sql = "select _wstart, _wend, tbname, 'xx' from st partition by tbname event_window start with a > 0 end with b = 2 slimit 2 limit 2;" | ||
Comment on lines +282 to +286 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||
| tdSql.query(sql) | ||
| tdSql.checkRows(4) | ||
| tdSql.checkData(0, 3, 'xx') | ||
| tdLog.info(f"======== test_event successfully executed") | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -149,7 +149,96 @@ def query(self): | ||
| tdSql.error( | ||
| f"select count(*) from dev_001 session(ts,1d) where ts <'2020-05-20 0:0:0'" | ||
| ) | ||
| sql = "select _wstart, _wend, 1, count(*) from dev_001 session(ts,1d)" | ||
| tdSql.query(sql) | ||
| tdSql.checkRows(4) | ||
| tdSql.checkData(0, 0, "2020-05-13 10:00:00.000") | ||
| tdSql.checkData(0, 1, "2020-05-14 13:00:00.001") | ||
| tdSql.checkData(0, 2, 1) | ||
| tdSql.checkData(0, 3, 13) | ||
| tdSql.checkData(1, 0, "2020-05-15 14:00:00.000") | ||
| tdSql.checkData(1, 1, "2020-05-15 14:00:00.000") | ||
| tdSql.checkData(1, 2, 1) | ||
| tdSql.checkData(2, 0, "2020-05-20 10:00:00.000") | ||
| tdSql.checkData(2, 1, "2020-05-20 10:00:00.000") | ||
| tdSql.checkData(2, 2, 1) | ||
| tdSql.checkData(3, 0, "2020-05-27 10:00:00.001") | ||
| tdSql.checkData(3, 1, "2020-05-27 10:00:00.001") | ||
| tdSql.checkData(3, 2, 1) | ||
| sql = "select _wstart, _wend, 1 from dev_001 session(ts,1d)" | ||
| tdSql.query(sql) | ||
| tdSql.checkRows(4) | ||
| tdSql.checkData(0, 0, "2020-05-13 10:00:00.000") | ||
| tdSql.checkData(0, 1, "2020-05-14 13:00:00.001") | ||
| tdSql.checkData(0, 2, 1) | ||
| tdSql.checkData(1, 0, "2020-05-15 14:00:00.000") | ||
| tdSql.checkData(1, 1, "2020-05-15 14:00:00.000") | ||
| tdSql.checkData(1, 2, 1) | ||
| tdSql.checkData(2, 0, "2020-05-20 10:00:00.000") | ||
| tdSql.checkData(2, 1, "2020-05-20 10:00:00.000") | ||
| tdSql.checkData(2, 2, 1) | ||
| tdSql.checkData(3, 0, "2020-05-27 10:00:00.001") | ||
| tdSql.checkData(3, 1, "2020-05-27 10:00:00.001") | ||
| tdSql.checkData(3, 2, 1) | ||
Comment on lines +153 to +185 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||
| sql = "select _wstart, _wend, 1, ts from dev_001 session(ts,1d);" | ||
| tdSql.error(sql) | ||
| sql = "select _wstart, _wend, 1, dev from dev_001 session(ts,1d)" | ||
| tdSql.error(sql) | ||
| sql = "select _wstart, _wend, 1, tbname, count(*) from st partition by tbname session(ts,1d) order by tbname;" | ||
| tdSql.query(sql) | ||
| tdSql.checkRows(5) | ||
| tdSql.checkData(0, 0, "2020-05-13 10:00:00.000") | ||
| tdSql.checkData(0, 1, "2020-05-14 13:00:00.001") | ||
| tdSql.checkData(0, 2, 1) | ||
| tdSql.checkData(0, 3, "dev_001") | ||
| tdSql.checkData(1, 0, "2020-05-15 14:00:00.000") | ||
| tdSql.checkData(1, 1, "2020-05-15 14:00:00.000") | ||
| tdSql.checkData(1, 2, 1) | ||
| tdSql.checkData(1, 3, "dev_001") | ||
| tdSql.checkData(2, 0, "2020-05-20 10:00:00.000") | ||
| tdSql.checkData(2, 1, "2020-05-20 10:00:00.000") | ||
| tdSql.checkData(2, 2, 1) | ||
| tdSql.checkData(2, 3, "dev_001") | ||
| tdSql.checkData(3, 0, "2020-05-27 10:00:00.001") | ||
| tdSql.checkData(3, 1, "2020-05-27 10:00:00.001") | ||
| tdSql.checkData(3, 2, 1) | ||
| tdSql.checkData(3, 3, "dev_001") | ||
| tdSql.checkData(4, 0, "2020-05-13 10:00:00.000") | ||
| tdSql.checkData(4, 1, "2020-05-13 10:00:00.510") | ||
| tdSql.checkData(4, 2, 1) | ||
| tdSql.checkData(4, 3, "dev_002") | ||
| sql = "select _wstart, _wend, 1, tbname from st partition by tbname session(ts,1d) order by tbname;" | ||
| tdSql.query(sql) | ||
| tdSql.checkRows(5) | ||
| tdSql.checkData(0, 0, "2020-05-13 10:00:00.000") | ||
| tdSql.checkData(0, 1, "2020-05-14 13:00:00.001") | ||
| tdSql.checkData(0, 2, 1) | ||
| tdSql.checkData(0, 3, "dev_001") | ||
| tdSql.checkData(1, 0, "2020-05-15 14:00:00.000") | ||
| tdSql.checkData(1, 1, "2020-05-15 14:00:00.000") | ||
| tdSql.checkData(1, 2, 1) | ||
| tdSql.checkData(1, 3, "dev_001") | ||
| tdSql.checkData(2, 0, "2020-05-20 10:00:00.000") | ||
| tdSql.checkData(2, 1, "2020-05-20 10:00:00.000") | ||
| tdSql.checkData(2, 2, 1) | ||
| tdSql.checkData(2, 3, "dev_001") | ||
| tdSql.checkData(3, 0, "2020-05-27 10:00:00.001") | ||
| tdSql.checkData(3, 1, "2020-05-27 10:00:00.001") | ||
| tdSql.checkData(3, 2, 1) | ||
| tdSql.checkData(3, 3, "dev_001") | ||
| tdSql.checkData(4, 0, "2020-05-13 10:00:00.000") | ||
| tdSql.checkData(4, 1, "2020-05-13 10:00:00.510") | ||
| tdSql.checkData(4, 2, 1) | ||
| tdSql.checkData(4, 3, "dev_002") | ||
Comment on lines +193 to +240 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||
| # print ====> select count(*) from dev_001 session(ts,1u) | ||
| # sql select _wstart, count(*) from dev_001 session(ts,1u) | ||
| # print rows: $rows | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -641,4 +641,26 @@ def Count1(self): | ||
| f"select _wstart, count(*) c1, tbname from st partition by tbname count_window(2) slimit 2 limit 2;" | ||
| ) | ||
| tdSql.checkRows(4) | ||
| sql = f"select _wstart, 1, ta, tb, tc, tbname from st partition by tbname count_window(2) slimit 2 limit 2;" | ||
| tdSql.query(sql) | ||
| tdSql.checkRows(4) | ||
| sql = f"select _wstart, 1, ta, tb, tc, tbname from t1 partition by tbname count_window(2) slimit 2 limit 2;" | ||
| tdSql.query(sql) | ||
| tdSql.checkRows(2) | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||
| sql = f"select _wstart, 1, ta, tb, tc, tbname from t1 count_window(2) slimit 2 limit 2;" | ||
| tdSql.error(sql) | ||
| sql = f"select _wstart, 1, ta, tb, tc, count(*), tbname from t1 count_window(2) slimit 2 limit 2;" | ||
| tdSql.error(sql) | ||
| sql = f"select _wstart, 1 from t1 count_window(2);" | ||
| tdSql.query(sql) | ||
| tdSql.checkRows(3) | ||
| sql = f"select _wstart, 1, count(*) from t1 count_window(2);" | ||
| tdSql.query(sql) | ||
Comment on lines +653 to +663 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. | ||
| tdSql.checkRows(3) | ||
| tdLog.info(f"query_count0 end") | ||
Uh oh!
There was an error while loading.Please reload this page.