You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/cases/18-StreamProcessing/02-Stream/stream_subq_in-mtables.py
+15-2Lines changed: 15 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -80,14 +80,27 @@ def prepareData(self):
80
80
self.tb_count=50
81
81
self.ts_step=1000
82
82
self.ts_total=5000000
83
+
83
84
fortinrange(0, self.tb_count):
84
85
sqls.append(f"create table db.d{t} using db.meters tags({t})")
85
-
foriinrange(0, self.ts_total, self.ts_step):
86
-
sqls.append(f"insert into db.d{t} values({ts+i},{i})")
87
86
88
87
tdSql.executes(sqls)
89
88
tdLog.info(f"create tables successfully.")
90
89
90
+
# Batch insert: 500 rows per INSERT statement
91
+
batch_size=500
92
+
row_count=self.ts_total//self.ts_step# 5000
93
+
fortinrange(0, self.tb_count):
94
+
forbatch_startinrange(0, row_count, batch_size):
95
+
batch_end=min(batch_start+batch_size, row_count)
96
+
values=" ".join(
97
+
f"({ts+i*self.ts_step},{i*self.ts_step})"
98
+
foriinrange(batch_start, batch_end)
99
+
)
100
+
tdSql.execute(f"insert into db.d{t} values {values}")
101
+
102
+
tdLog.info(f"insert data successfully.")
103
+
91
104
defcreateStream(self):
92
105
tdLog.info(f"create stb stream.")
93
106
#sql = (f"create stream db.stb_stream count_window(2, 1) from db.meters partition by tbname,groupid stream_options(fill_history('2026-01-01 00:00:00')|low_latency_calc) into db.stream_meters output_subtable (concat('sm#', tbname)) tags (groupid int as groupid) as select _twstart as ts, first(current) as ff1, last(current) as lf1 from %%tbname where ts>= _twstart and ts<= _twend and current > (select first(current)-1 from db.meters);")
0 commit comments