我正在尝试使用运动学分析为实时排行榜做一个概念证明,并尝试使用他们的入门示例,演示股票行情自动收录器数据流中的时间段示例。但是,当我尝试模拟按价格排序的页首横幅时,出现错误Leading column in ORDER BY must be monotonic
。
SELECT from and INSERT into like a TABLE
-- PUMP: an entity used to continuously 'SELECT ... FROM' a source STREAM, and INSERT SQL results into an output STREAM
-- Create output stream, which can be used to send to a destination
CREATE OR REPLACE STREAM "DESTINATION_SQL_STREAM" (ticker_symbol VARCHAR(4), price REAL);
-- Create a pump which continuously selects from a source stream (SOURCE_SQL_STREAM_001)
-- performs an aggregate count that is grouped by columns ticker over a 10-second tumbling window
-- and inserts into output stream (DESTINATION_SQL_STREAM)
CREATE OR REPLACE PUMP "STREAM_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM"
-- Aggregate function COUNT|AVG|MAX|MIN|SUM|STDDEV_POP|STDDEV_SAMP|VAR_POP|VAR_SAMP)
SELECT STREAM ticker_symbol, price
FROM "SOURCE_SQL_STREAM_001"
ORDER BY price desc
-- Uses a 10-second tumbling time window
GROUP BY ticker_symbol, price, FLOOR(("SOURCE_SQL_STREAM_001".ROWTIME - TIMESTAMP '1970-01-01 00:00:00') SECOND / 10 TO SECOND);
答案 0 :(得分:0)
According to the documentation,除单调外,ORDER BY还必须基于时间:
如果流查询的前导表达式为,则可以使用ORDER BY 基于时间的单调
在您的情况下,您似乎正在计算GROUP BY中的时间戳,但是您必须将相同的计算结果添加到ORDER BY中(或者可能想出一种方法来在SELECT中进行选择并赋予它列别名)。