You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by 杨力 <bi...@gmail.com> on 2018/03/05 10:26:00 UTC

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

Re: Using time window with SQL nested query

Posted by 杨力 <bi...@gmail.com>.
Thanks. It works. I missed it while reading the document.

Timo Walther <tw...@apache.org> 于 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 杨力:
>
>
>

Re: Using time window with SQL nested query

Posted by Timo Walther <tw...@apache.org>.
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