Logging.debug("[OPS] database dropped at {}".format(time.time()))
'''
# Streams will generator TD-20237 (it will crash taosd , start this task when this issue fixed )
class TaskCreateStream(StateTransitionTask):
@classmethod
...
...
@@ -1707,9 +1728,9 @@ class TaskCreateStream(StateTransitionTask):
# wt.execSql("use db") # should always be in place
# create stream
'''
CREATE STREAM avg_vol_s INTO avg_vol AS SELECT _wstartts, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVAL(1m) SLIDING(30s);
'''
# CREATE STREAM avg_vol_s INTO avg_vol AS SELECT _wstartts, count(*), avg(voltage) FROM meters PARTITION BY tbname INTERVAL(1m) SLIDING(30s);
stbname =sTable.getName()
sub_tables = sTable.getRegTables(wt.getDbConn())
aggExpr = Dice.choice([
...
...
@@ -1735,7 +1756,7 @@ class TaskCreateStream(StateTransitionTask):
if sub_tables: # if not empty
sub_tbname = sub_tables[0]
# create stream with query above sub_table
stream_sql='create stream {} into {}.{} as select {}, avg(speed) FROM {}.{} where ts <now and ts >now -1h PARTITION BY tbname INTERVAL(5s) SLIDING(3s) FILL (prev) '.format(sub_stream_name,dbname,sub_stream_tb_name,aggExpr,dbname,sub_tbname)
stream_sql = 'create stream {} into {}.{} as select {}, avg(speed) FROM {}.{} PARTITION BY tbname INTERVAL(5s) SLIDING(3s) '.format(sub_stream_name,dbname,sub_stream_tb_name ,aggExpr,dbname,sub_tbname)
try:
self.execWtSql(wt, stream_sql)
Logging.debug("[OPS] stream is creating at {}".format(time.time()))
...
...
@@ -1749,7 +1770,7 @@ class TaskCreateStream(StateTransitionTask):
pass
else:
stream_sql='create stream {} into {}.{} as select {}, avg(speed) FROM {}.{} where ts <now and ts >now -1h PARTITION BY tbname INTERVAL(5s) SLIDING(3s) FILL (prev) '.format(super_stream_name,dbname,super_stream_tb_name,aggExpr,dbname,stbname)
stream_sql = 'create stream {} into {}.{} as select {}, avg(speed) FROM {}.{} PARTITION BY tbname INTERVAL(5s) SLIDING(3s) '.format(super_stream_name,dbname,super_stream_tb_name,aggExpr, dbname,stbname)
try:
self.execWtSql(wt, stream_sql)
...
...
@@ -1759,8 +1780,142 @@ class TaskCreateStream(StateTransitionTask):