dianfu commented on a change in pull request #8401: [FLINK-12407][python] Add 
all table operators align Java Table API.
URL: https://github.com/apache/flink/pull/8401#discussion_r283169262
 
 

 ##########
 File path: flink-python/pyflink/table/table.py
 ##########
 @@ -118,3 +463,112 @@ def insert_into(self, table_name):
         :param table_name: Name of the :class:`TableSink` to which the 
:class:`Table` is written.
         """
         self._j_table.insertInto(table_name)
+
+    def __str__(self):
+        return self._j_table.toString()
+
+
+class GroupedTable(object):
+    """
+    A table that has been grouped on a set of grouping keys.
+    """
+
+    def __init__(self, java_table):
+        self._j_table = java_table
+
+    def select(self, fields):
+        """
+        Performs a selection operation on a grouped table. Similar to an SQL 
SELECT statement.
+        The field expressions can contain complex expressions and aggregations.
+
+        Example:
+        ::
+            >>> tab.group_by("key").select("key, value.avg + ' The average' as 
average")
+
+
+        :param fields: Expression string that contains group keys and 
aggregate function calls.
+        :return: Result table.
+        """
+        return Table(self._j_table.select(fields))
+
+
+class GroupWindowedTable(object):
+    """
+    A table that has been windowed for :class:`GroupWindow`s.
+    """
+
+    def __init__(self, java_group_windowed_table):
+        self._java_table = java_group_windowed_table
+
+    def group_by(self, fields):
+        """
+        Groups the elements by a mandatory window and one or more optional 
grouping attributes.
+        The window is specified by referring to its alias.
+
+        If no additional grouping attribute is specified and if the input is a 
streaming table,
+        the aggregation will be performed by a single task, i.e., with 
parallelism 1.
+
+        Aggregations are performed per group and defined by a subsequent
+        :func:`~pyflink.table.WindowGroupedTable.select` clause similar to SQL 
SELECT-GROUP-BY
+        query.
+
+        Example:
+        ::
+            >>> tab.window(groupWindow.alias("w")).group_by("w, 
key").select("key, value.avg")
+
+        :param fields: Group keys.
+        :return: A :class:`WindowGroupedTable`.
+        """
+        return WindowGroupedTable(self._java_table.groupBy(fields))
+
+
+class WindowGroupedTable(object):
+    """
+    A table that has been windowed and grouped for :class:`GroupWindow`s.
+    """
+
+    def __init__(self, java_window_grouped_table):
+        self._java_table = java_window_grouped_table
+
+    def select(self, fields):
+        """
+        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:
+        ::
+            >>> window_grouped_table.select("key, window.start, value.avg as 
valavg")
+
+        :param fields: Expression string.
+        :return: Result table.
+        """
+        return Table(self._java_table.select(fields))
+
+
+class OverWindowedTable(object):
+    """
+    A table that has been windowed for :class:`OverWindow`s.
+
+    Unlike group windows, which are specified in the GROUP BY clause, over 
windows do not collapse
+    rows. Instead over window aggregates compute an aggregate for each input 
row over a range of
+    its neighboring rows.
+    """
+
+    def __init__(self, java_over_windowed_table):
+        self._java_table = java_over_windowed_table
 
 Review comment:
   _java_table -> _j_over_windowed_table

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to