My problem is that I cannot use the ORDER BY
clause after the JOIN
operation. To reproduce the problem,
CREATE TABLE stack (
id INT PRIMARY KEY,
ts TIMESTAMP(3),
WATERMARK FOR ts AS ts - INTERVAL '1' SECONDS
) WITH (
'connector' = 'datagen',
'rows-per-second' = '5',
'fields.id.kind'='sequence',
'fields.id.start'='1',
'fields.id.end'='100'
);
This table has a watermark strategy and TIMESTAMP(3) *ROWTIME*
type on ts
.
Flink SQL> DESC stack;
+------+------------------------+-------+---------+--------+----------------------------+
| name | type | null | key | extras | watermark |
+------+------------------------+-------+---------+--------+----------------------------+
| id | INT | FALSE | PRI(id) | | |
| ts | TIMESTAMP(3) *ROWTIME* | TRUE | | | `ts` - INTERVAL '1' SECOND |
+------+------------------------+-------+---------+--------+----------------------------+
2 rows in set
However, if I define a view as a simple self-join
CREATE VIEW self_join AS (
SELECT l.ts, l.id, r.id
FROM stack as l INNER JOIN stack as r
ON l.id=r.id
);
it loses the watermark strategy but not the type,
Flink SQL> DESC self_join;
+------+------------------------+-------+-----+--------+-----------+
| name | type | null | key | extras | watermark |
+------+------------------------+-------+-----+--------+-----------+
| ts | TIMESTAMP(3) *ROWTIME* | TRUE | | | |
| id | INT | FALSE | | | |
| id0 | INT | FALSE | | | |
+------+------------------------+-------+-----+--------+-----------+
3 rows in set
I assume that we can preserve the watermark strategy and use ORDER BY
after a JOIN
operation but this is not the case. How can I add a watermark strategy again to the VIEW
?
Thanks in advance.