[ https://issues.apache.org/jira/browse/FLINK-5386?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15830001#comment-15830001 ]
ASF GitHub Bot commented on FLINK-5386: --------------------------------------- Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/3046#discussion_r96860442 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/table.scala --- @@ -855,57 +858,45 @@ class GroupedTable( val fieldExprs = ExpressionParser.parseExpressionList(fields) select(fieldExprs: _*) } - - /** - * Groups the records of a table by assigning them to windows defined by a time or row interval. - * - * For streaming tables of infinite size, grouping into windows is required to define finite - * groups on which group-based aggregates can be computed. - * - * For batch tables of finite size, windowing essentially provides shortcuts for time-based - * groupBy. - * - * @param groupWindow group-window that specifies how elements are grouped. - * @return A windowed table. - */ - def window(groupWindow: GroupWindow): GroupWindowedTable = { - new GroupWindowedTable(table, groupKey, groupWindow) - } } -class GroupWindowedTable( +class WindowGroupedTable( private[flink] val table: Table, private[flink] val groupKey: Seq[Expression], - private[flink] val window: GroupWindow) { + private[flink] val window: Window) { /** - * Performs a selection operation on a windowed table. Similar to an SQL SELECT statement. + * Performs a selection operation on a window grouped table. Similar to an SQL SELECT statement. * The field expressions can contain complex expressions and aggregations. * * Example: * * {{{ - * groupWindowTable.select('key, 'window.start, 'value.avg + " The average" as 'average) + * windowGroupedTable.select('key, 'window.start, 'value.avg + " The average" as 'average) * }}} */ def select(fields: Expression*): Table = { + // get group keys by removing window column --- End diff -- window column -> window alias > Refactoring Window Clause > ------------------------- > > Key: FLINK-5386 > URL: https://issues.apache.org/jira/browse/FLINK-5386 > Project: Flink > Issue Type: Sub-task > Components: Table API & SQL > Reporter: sunjincheng > Assignee: sunjincheng > > Similar to the SQL, window clause is defined "as" a symbol which is > explicitly used in groupby/over. We are proposing to refactor the way to > write groupby+window tableAPI as follows: > {code} > tab //Table('a,'b,'c) > .window( Slide over 10.milli every 5.milli as 'w1as 'w1) // WindowedTable > .groupBy('w1,'a,'b) // WindowGroupedTable > .select('a,'b,c.count as 'mycount) // Table > .window(Tumble over 5.milli on 'b as 'w2) > .groupBy('w2) > .select('a.count, 'w2.start, 'w2.end) > {code} > In this way, for row-window, we anyway need to define window clause as a > symbol. This change will make the API of window and row-window consistent, > example for row-window: > {code} > .window(RowXXXWindow as ‘x, RowYYYWindow as ‘y) // WindowedTable > .select(‘a, ‘b.count over ‘x as ‘xcnt, ‘c.count over ‘y as ‘ycnt, ‘x.start, > ‘x.end) > {code} > What do you think? [~fhueske] [~twalthr] -- This message was sent by Atlassian JIRA (v6.3.4#6332)