[ 
https://issues.apache.org/jira/browse/FLINK-24024?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

JING ZHANG updated FLINK-24024:
-------------------------------
    Description: 
There is a syntax mistake in session Window TVF in FLINK-23544 .

For example, the following SQL has syntax mistake.

 
{code:java}
"""
  |SELECT
  |   a,
  |   window_start,
  |   window_end,
  |   count(*),
  |   sum(d),
  |   max(d) filter (where b > 1000),
  |   count(distinct c) AS uv
  |FROM TABLE(
  |  SESSION(
  |    TABLE MyTable, 
  |    DESCRIPTOR(proctime), 
  |    INTERVAL '5' MINUTE))
  |GROUP BY a, window_start, window_end
""".stripMargin
{code}
 

It should updated to the following SQL, while partition key (a) should be moved 
into SESSION

Window TVF based on Calcite [SESSION window 
TVF|https://calcite.apache.org/docs/reference.html#session].

 
{code:java}
val sql =
  """
    |SELECT
    |   a,
    |   window_start,
    |   window_end,
    |   count(*),
    |   sum(d),
    |   max(d) filter (where b > 1000),
    |   count(distinct c) AS uv
    |FROM TABLE(
    |  SESSION(
    |    TABLE MyTable,
    |    DESCRIPTOR(proctime),
    |    DESCRIPTOR(a)
    |    INTERVAL '5' MINUTE))
    |GROUP BY a, window_start, window_end
  """.stripMargin{code}
 

To fix the bug, we only need update Session Window TVF syntax, we don't need 
update the operator part.

Besides, we should check group keys of window aggregate should only contain 
window_start, window_end, partition_key. group keys could not contain other 
fields. 

  was:
There is a syntax mistake in session Window TVF in FLINK-23543.

For example, the following SQL has syntax mistake.

 
{code:java}
"""
  |SELECT
  |   a,
  |   window_start,
  |   window_end,
  |   count(*),
  |   sum(d),
  |   max(d) filter (where b > 1000),
  |   count(distinct c) AS uv
  |FROM TABLE(
  |  SESSION(
  |    TABLE MyTable, 
  |    DESCRIPTOR(proctime), 
  |    INTERVAL '5' MINUTE))
  |GROUP BY a, window_start, window_end
""".stripMargin
{code}
 

It should updated to the following SQL, while partition key (a) should be moved 
into SESSION

Window TVF based on Calcite [SESSION window 
TVF|https://calcite.apache.org/docs/reference.html#session].

 
{code:java}
val sql =
  """
    |SELECT
    |   a,
    |   window_start,
    |   window_end,
    |   count(*),
    |   sum(d),
    |   max(d) filter (where b > 1000),
    |   count(distinct c) AS uv
    |FROM TABLE(
    |  SESSION(
    |    TABLE MyTable,
    |    DESCRIPTOR(proctime),
    |    DESCRIPTOR(a)
    |    INTERVAL '5' MINUTE))
    |GROUP BY a, window_start, window_end
  """.stripMargin{code}
 

To fix the bug, we only need update Session Window TVF syntax, we don't need 
update the operator part.

Besides, we should check group keys of window aggregate should only contain 
window_start, window_end, partition_key. group keys could not contain other 
fields. 


> Fix syntax mistake in session Window TVF 
> -----------------------------------------
>
>                 Key: FLINK-24024
>                 URL: https://issues.apache.org/jira/browse/FLINK-24024
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / API
>    Affects Versions: 1.14.0
>            Reporter: JING ZHANG
>            Assignee: JING ZHANG
>            Priority: Blocker
>              Labels: pull-request-available
>             Fix For: 1.14.0, 1.15.0
>
>
> There is a syntax mistake in session Window TVF in FLINK-23544 .
> For example, the following SQL has syntax mistake.
>  
> {code:java}
> """
>   |SELECT
>   |   a,
>   |   window_start,
>   |   window_end,
>   |   count(*),
>   |   sum(d),
>   |   max(d) filter (where b > 1000),
>   |   count(distinct c) AS uv
>   |FROM TABLE(
>   |  SESSION(
>   |    TABLE MyTable, 
>   |    DESCRIPTOR(proctime), 
>   |    INTERVAL '5' MINUTE))
>   |GROUP BY a, window_start, window_end
> """.stripMargin
> {code}
>  
> It should updated to the following SQL, while partition key (a) should be 
> moved into SESSION
> Window TVF based on Calcite [SESSION window 
> TVF|https://calcite.apache.org/docs/reference.html#session].
>  
> {code:java}
> val sql =
>   """
>     |SELECT
>     |   a,
>     |   window_start,
>     |   window_end,
>     |   count(*),
>     |   sum(d),
>     |   max(d) filter (where b > 1000),
>     |   count(distinct c) AS uv
>     |FROM TABLE(
>     |  SESSION(
>     |    TABLE MyTable,
>     |    DESCRIPTOR(proctime),
>     |    DESCRIPTOR(a)
>     |    INTERVAL '5' MINUTE))
>     |GROUP BY a, window_start, window_end
>   """.stripMargin{code}
>  
> To fix the bug, we only need update Session Window TVF syntax, we don't need 
> update the operator part.
> Besides, we should check group keys of window aggregate should only contain 
> window_start, window_end, partition_key. group keys could not contain other 
> fields. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to