Using time window with SQL nested query

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Using time window with SQL nested query

杨力
I tried to use write a nested query with HOP window in a streaming environment.

Table `source` consists of 3 column, a, b, and timestamp.

SELECT a FROM (SELECT a, COUNT(*) FROM source GROUP BY HOP(timestamp, ..., ...), a, b) GROUP BY HOP(timestamp, ..., ...), a HAVING ...

And flink throws an exception of "Column 'timestamp' not found in any table".

And I tried to "SELECT HOP_END(timestamp, ..., ...) AS timestamp, a, COUNT(*)" in the inner query, getting an exception of "Window can only be defined over a time attribute column."

Can I make the rowtime attribute propagating to the outer query, just like chaining windows in DataStream API?

Regrads,
Bill
Reply | Threaded
Open this post in threaded view
|

Re: Using time window with SQL nested query

Timo Walther
Hi Bill,

you can use HOP_ROWTIME()/HOP_PROCTIME() to propagate the time attribute to the outer query. See also [1] for an example.

Regards,
Timo

[1] https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/table/sql.html#selecting-group-window-start-and-end-timestamps



Am 3/5/18 um 11:26 AM schrieb 杨力:
I tried to use write a nested query with HOP window in a streaming environment.

Table `source` consists of 3 column, a, b, and timestamp.

SELECT a FROM (SELECT a, COUNT(*) FROM source GROUP BY HOP(timestamp, ..., ...), a, b) GROUP BY HOP(timestamp, ..., ...), a HAVING ...

And flink throws an exception of "Column 'timestamp' not found in any table".

And I tried to "SELECT HOP_END(timestamp, ..., ...) AS timestamp, a, COUNT(*)" in the inner query, getting an exception of "Window can only be defined over a time attribute column."

Can I make the rowtime attribute propagating to the outer query, just like chaining windows in DataStream API?

Regrads,
Bill


Reply | Threaded
Open this post in threaded view
|

Re: Using time window with SQL nested query

杨力
Thanks. It works. I missed it while reading the document.

Timo Walther <[hidden email]> 于 2018年3月5日周一 下午9:20写道:
Hi Bill,

you can use HOP_ROWTIME()/HOP_PROCTIME() to propagate the time attribute to the outer query. See also [1] for an example.

Regards,
Timo

[1] https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/table/sql.html#selecting-group-window-start-and-end-timestamps



Am 3/5/18 um 11:26 AM schrieb 杨力: