Skip to content

Commit 43c21c4

Browse files
committed
test:Add more
1 parent dbfb5a5 commit 43c21c4

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

test/cases/13-StreamProcessing/99-Others/test_trigger_type_4.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ def test_stream_trigger_type1(self):
6565
sql7 = "create stream s7 state_window (c1) from stream_trigger partition by tbname options(fill_history_first(1)) into st7 as select _twstart, avg(cint), count(cint) from meters;"
6666
sql8 = "create stream s8 state_window (c1) from stream_trigger partition by tbname into st8 as select _twstart ts, count(*) c1, avg(cint) c2, _twstart + 1 as ts2 from meters;"
6767
sql9 = "create stream s9 PERIOD(10s, 10a) into st9 as select cast(_tlocaltime/1000000 as timestamp) as tl, _tprev_localtime/1000000 tp, _tnext_localtime/1000000 tn, now, max(cint) from meters;"
68-
# #new stream with session
69-
#sql11 = "create stream s11 session(ts,1a) from stream_trigger partition by tbname into st11 as select _twstart ts, count(*) c1, avg(cint) c2 from meters where cts >= _twstart and cts < _twend;"
70-
#sql12 = "create stream s12 session(ts,1a) from stream_trigger into st12 as select _twstart ts, count(*) c1, avg(cint) c2 from meters where cts >= _twstart and cts < _twend;"
68+
69+
70+
sql11 = "create stream s11 session(ts,1a) from stream_trigger partition by tbname into st11 as select _twstart ts, count(*) c1, avg(cint) c2 from meters where cts >= _twstart and cts <= _twend;"
71+
sql12 = "create stream s12 session(ts,1a) from stream_trigger into st12 as select _twstart ts, count(*) c1, avg(cint) c2 from meters where cts >= _twstart and cts <= _twend;"
7172
sql13 = "create stream s13 session(ts,1a) from stream_trigger into st13 as select _twstart ts, count(*) c1, avg(cint) c2 from meters;"
7273
sql14 = "create stream s14 session(ts,1a) from stream_trigger into st14 as select _twstart ts, count(*) c1, avg(c2) c2 from %%trows;"
7374

@@ -85,13 +86,13 @@ def test_stream_trigger_type1(self):
8586
# self.StreamItem(sql6, self.checks6),
8687
# self.StreamItem(sql7, self.checks7),
8788
# self.StreamItem(sql8, self.checks8),
88-
# self.StreamItem(sql9, self.checks9),
89-
# #self.StreamItem(sql11, self.checks11),
90-
# # self.StreamItem(sql12, self.checks12),
89+
# self.StreamItem(sql9, self.checks9),#113、114
90+
self.StreamItem(sql11, self.checks11),#116
91+
# self.StreamItem(sql12, self.checks12), #117
9192
# self.StreamItem(sql13, self.checks13),
9293
# self.StreamItem(sql14, self.checks14),
9394
# self.StreamItem(sql21, self.checks21),
94-
self.StreamItem(sql22, self.checks22),
95+
#self.StreamItem(sql22, self.checks22), #115
9596
]
9697

9798
for stream in streams:
@@ -101,10 +102,30 @@ def test_stream_trigger_type1(self):
101102
tdLog.info(f"=============== write trigger data")
102103
sql = "insert into stream_trigger values ('2025-01-01 00:00:00', 0, 0), ('2025-01-01 00:00:01', 1, 1), ('2025-01-01 00:00:02', 2, 2);"
103104
tdSql.execute(sql)
105+
106+
tdLog.info(f"=============== create vtable")
107+
sql = """create vtable v1 (
108+
ts timestamp,
109+
t1_cint int from t1.cint,
110+
t1_cuint INT UNSIGNED from t1.cuint,
111+
t2_cint int from t2.cint,
112+
t2_cuint INT UNSIGNED from t2.cuint,
113+
stream_trigger_c1 int from stream_trigger.c1,
114+
stream_trigger_c2 int from stream_trigger.c2);"""
115+
tdSql.execute(sql)
104116

105117
tdLog.info(f"=============== check stream result")
106118
for stream in streams:
107119
stream.check()
120+
121+
122+
# tdLog.info(f"=============== write trigger data again")
123+
# sql = "insert into stream_trigger values ('2025-01-01 00:00:00', 0, 0), ('2025-01-01 00:00:01', 1, 0), ('2025-01-01 00:00:02', 2, 2);"
124+
# tdSql.execute(sql)
125+
126+
# tdLog.info(f"=============== check stream result")
127+
# for stream in streams:
128+
# stream.check()
108129

109130
def checks1(self):
110131
result_sql = "select ts, c1, c2 from qdb.st1"
@@ -237,18 +258,14 @@ def checks9(self):
237258

238259

239260
def checks11(self):
240-
result_sql = "select ts, c1, c2, ts2 from qdb.st11"
261+
result_sql = "select ts, c1, c2 from qdb.st11"
241262
tdSql.checkResultsByFunc(
242263
sql=result_sql,
243264
func=lambda: tdSql.getRows() == 2
244265
and tdSql.compareData(0, 0, "2025-01-01 00:00:00.000")
245-
and tdSql.compareData(0, 1, 6)
246-
and tdSql.compareData(0, 3, "2025-01-01 00:00:00.001")
247-
and tdSql.compareData(0, 2, 1.5)
266+
and tdSql.compareData(0, 1, 3)
248267
and tdSql.compareData(1, 0, "2025-01-01 00:00:01.000")
249-
and tdSql.compareData(1, 1, 6)
250-
and tdSql.compareData(1, 2, 1.5)
251-
and tdSql.compareData(1, 3, "2025-01-01 00:00:01.001"),
268+
and tdSql.compareData(1, 1, 3),
252269
)
253270

254271
def checks12(self):

0 commit comments

Comments
 (0)