I am trying to run the following SQL statement on Flink version 1.10
select startAreaID, endAreaID
from (
select startAreaID, endAreaID,
ROW_NUMBER() OVER (ORDER BY cnt DESC ) as row_num
from (
select startAreaID, endAreaID, count(1) as cnt
from
(
select * from Rides
Match_Recognize
(
PARTITION BY taxiId
Order by rideTime
MEASURES
toAreaId(S.lon, S.lat) as startAreaID,
toAreaId(E.lon, E.lat) as endAreaID,
MATCH_ROWTIME() as matchTime
AFTER MATCH SKIP PAST LAST ROW
PATTERN (S E)
DEFINE
S AS S.isStart=True,
E AS E.isStart=False
)) as routes
group by startAreaID,endAreaID, tumble(matchTime, interval '30' minute)
) as wins
)
where row_num <= 10;
I get the error [ERROR] Could not execute SQL statement. Reason: org.apache.flink.table.api.TableException: This calc has no useful projection and no filter. It should be removed by CalcRemoveRule.
I would like help to identify what is wrong with the statement. Is it too complex? Should I register intermediate results as views?
NOTE: The data is read from a Kafka source of rides with the schema
rideId: BIGINT taxiId: BIGINT isStart: BOOLEAN lon: FLOAT lat: FLOAT rideTime: TIMESTAMP(3) ROWTIME psgCnt: INT