You can change to "order by eventTIme". And it should work.

You can sort on event time, but it must be time-ascending-order without 'limit'.
If you still want to a descending order, I think you can try to set the 
internal configuration `__table.exec.sort.non-temporal.enabled__` to true.
But remember it's just experimental, which may bring unexpect behavior.

Best regards,
Yuxia

----- 原始邮件 -----
发件人: "Noel OConnor" <noel.ocon...@gmail.com>
收件人: "User" <user@flink.apache.org>
发送时间: 星期二, 2022年 9 月 27日 上午 2:10:36
主题: Sorting by source event time

Hi,
I have a temporary view created from a datastream.

        tableEnv.createTemporaryView("productDetailsView", productStream,
                Schema.newBuilder()
                        .columnByMetadata("eventTime",
"TIMESTAMP_LTZ(3)", "rowtime", Boolean.TRUE)
                        .watermark("eventTime", "SOURCE_WATERMARK()")
                        .build());


and i'm trying to sort it using the following

Table resultTable2 = tableEnv.sqlQuery(
        "SELECT * FROM productDetailsView ORDER BY eventTime DESC");

but I get the following error

Caused by: org.apache.flink.table.api.TableException: Sort on a
non-time-attribute field is not supported.

Can you sort on event time or does it have to be part of the actual
payload data type?
Have I missed something obvious ?

cheers
Noel

Reply via email to