I have a streaming input, say stock price data (including multiple stocks), and I want to do a ranking by their price every 1 minutes. The ranking is based on all stocks' latest price and needs to sort all of them no matter if it was updated in the previous 1 minute or not. I tried to use ORDER BY in flink stream SQL.
I failed to implement my logic and I am confused about two parts:
Why can
ORDER BY
only use a time attribute as primary and only supportASC
? How can I implement an order by an other type like price?What does the below SQL (from the Flink document) mean? There is no window and there is no window so I assume the SQL will be executed immediately for each order come in, in that case, it looks meaningless to sort one element.
[Update]: When I read the code of ProcimeSortProcessFunction.scala, it seems that Flink sorts the elements received during the next one millisecond.
SELECT *
FROM Orders
ORDER BY orderTime
Finally, is there a way to implement my logic in SQL?