我在influxdb中具有以下CQ,可将来自测量row
的有价证券交易下采样为5分钟汇总,并将其插入到测量main
CREATE CONTINUOUS QUERY "trade_agg" ON stocks
BEGIN
SELECT FIRST(price) as open, LAST(price) as close, MAX(price) as high, MIN(price) as low, SUM(volume) as volume
INTO main
FROM raw
GROUP BY symbol, symbol_code, time(5m) fill(previous)
END
raw
的特定股票外观如下:
select * from raw where symbol = 'AMOC' order by time desc limit 20
name: raw
time price price_2 symbol symbol_code volume
---- ----- ------- ------ ----------- ------
[// lots more points here from 11:27 - 11:29, omitted for brevity]
2019-05-13T11:25:48Z 4.5 4.5 AMOC EGS380P1C010 5000
2019-05-13T11:25:44Z 4.51 4.51 AMOC EGS380P1C010 35
2019-05-13T11:25:44Z 4.5 4.5 AMOC EGS380P1C010 3000
2019-05-13T11:24:04Z 4.52 4.52 AMOC EGS380P1C010 2000
2019-05-13T11:23:31Z 4.5 4.5 AMOC EGS380P1C010 20000
2019-05-13T11:22:47Z 4.49 4.49 AMOC EGS380P1C010 500
2019-05-13T11:21:59Z 4.51 4.51 AMOC EGS380P1C010 1700
2019-05-13T11:21:59Z 4.52 4.52 AMOC EGS380P1C010 500
2019-05-13T11:21:53Z 4.46 4.46 AMOC EGS380P1C010 1000
2019-05-13T11:21:52Z 4.51 4.51 AMOC EGS380P1C010 2000
2019-05-13T11:20:01Z 4.5 4.5 AMOC EGS380P1C010 2243
问题是由于某种原因,CQ并未选择它应该选择的所有行,因此插入了main
:
select * from main where symbol = 'AMOC' order by time desc limit 5
name: main
time close high low open symbol symbol_code volume
---- ----- ---- --- ---- ------ ----------- ------
2019-05-13T11:20:00Z 4.5 4.5 4.5 4.5 AMOC EGS380P1C010 2243
2019-05-13T09:25:00Z 4.44 4.44 4.44 4.44 AMOC EGS380P1C010 1000
这是当天插入的仅有的两行。其他所有股票也都在发生这种情况。为什么会这样?