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

Aleksandra Cz updated FLINK-20361:
----------------------------------
    Description: 
In [Table walkthrough| 
[https://github.com/apache/flink-playgrounds/blob/master/table-walkthrough/src/main/java/org/apache/flink/playgrounds/spendreport/SpendReport.java]]
 

current Date time is defined as: 

{code:java}
    private static final LocalDateTime DATE_TIME = LocalDateTime.of(2020, 1, 1, 
0, 0);

{code}


If implemented *report* method would be as follows:

 
{code:java}
public static Table report(Table transactions) {
    return transactions
            
.window(Slide.over(lit(1).hours()).every(lit(5).minute()).on($("transaction_time")).as("log_ts"))
            .groupBy($("log_ts"),$("account_id"))
            .select(
                    $("log_ts").start().as("log_ts_start"),
                    $("log_ts").end().as("log_ts_end"),
                    $("account_id"),
                    $("amount").sum().as("amount"));
{code}
 

Then the resulting sliding window start and sliding window end would be in year 
1969/1970 instead of 2020. Please see first 3 elements of resulting table: 
{code:java}
[1969-12-31T23:05,1970-01-01T00:05,3,432, 
1969-12-31T23:10,1970-01-01T00:10,3,432, 
1969-12-31T23:15,1970-01-01T00:15,3,432]{code}

This behaviour repeats if using SQL instead of Table API,
it does not repeat for window duration of minutes, nor in Tumbling window.

  was:
If in [Table walkthrough| 
[https://github.com/apache/flink-playgrounds/blob/master/table-walkthrough/src/main/java/org/apache/flink/playgrounds/spendreport/SpendReport.java]]
 

current Date time is defined as: 

{code:java}
    private static final LocalDateTime DATE_TIME = LocalDateTime.of(2020, 1, 1, 
0, 0);

{code}


implemented *report* method would be as follows:

 
{code:java}
public static Table report(Table transactions) {
    return transactions
            
.window(Slide.over(lit(1).hours()).every(lit(5).minute()).on($("transaction_time")).as("log_ts"))
            .groupBy($("log_ts"),$("account_id"))
            .select(
                    $("log_ts").start().as("log_ts_start"),
                    $("log_ts").end().as("log_ts_end"),
                    $("account_id"),
                    $("amount").sum().as("amount"));
{code}
 

Then the resulting sliding window start and sliding window end would be in year 
1969/1970 instead of 2020. Please see first 3 elements of resulting table: 
{code:java}
[1969-12-31T23:05,1970-01-01T00:05,3,432, 
1969-12-31T23:10,1970-01-01T00:10,3,432, 
1969-12-31T23:15,1970-01-01T00:15,3,432]{code}

This behaviour repeats if using SQL instead of Table API,
it does not repeat for window duration of minutes, nor in Tumbling window.


> Using sliding window with duration of hours in Table API returns wrong time
> ---------------------------------------------------------------------------
>
>                 Key: FLINK-20361
>                 URL: https://issues.apache.org/jira/browse/FLINK-20361
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / API
>    Affects Versions: 1.11.0, 1.11.1, 1.11.2
>         Environment: Java 11, test executed in IntelliJ IDE on mac OS.
>            Reporter: Aleksandra Cz
>            Priority: Blocker
>
> In [Table walkthrough| 
> [https://github.com/apache/flink-playgrounds/blob/master/table-walkthrough/src/main/java/org/apache/flink/playgrounds/spendreport/SpendReport.java]]
>  
> current Date time is defined as: 
> {code:java}
>     private static final LocalDateTime DATE_TIME = LocalDateTime.of(2020, 1, 
> 1, 0, 0);
> {code}
> If implemented *report* method would be as follows:
>  
> {code:java}
> public static Table report(Table transactions) {
>     return transactions
>             
> .window(Slide.over(lit(1).hours()).every(lit(5).minute()).on($("transaction_time")).as("log_ts"))
>             .groupBy($("log_ts"),$("account_id"))
>             .select(
>                     $("log_ts").start().as("log_ts_start"),
>                     $("log_ts").end().as("log_ts_end"),
>                     $("account_id"),
>                     $("amount").sum().as("amount"));
> {code}
>  
> Then the resulting sliding window start and sliding window end would be in 
> year 1969/1970 instead of 2020. Please see first 3 elements of resulting 
> table: 
> {code:java}
> [1969-12-31T23:05,1970-01-01T00:05,3,432, 
> 1969-12-31T23:10,1970-01-01T00:10,3,432, 
> 1969-12-31T23:15,1970-01-01T00:15,3,432]{code}
> This behaviour repeats if using SQL instead of Table API,
> it does not repeat for window duration of minutes, nor in Tumbling window.



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

Reply via email to