You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Noel OConnor <no...@gmail.com> on 2022/09/26 18:10:36 UTC

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

Re: Sorting by source event time

Posted by Noel OConnor <no...@gmail.com>.
yep that worked, thanks for the help

On Tue, Sep 27, 2022 at 3:05 AM yuxia <lu...@alumni.sjtu.edu.cn> wrote:
>
> 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" <no...@gmail.com>
> 收件人: "User" <us...@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

Re: Sorting by source event time

Posted by yuxia <lu...@alumni.sjtu.edu.cn>.
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" <no...@gmail.com>
收件人: "User" <us...@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