WeiZhong94 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_r283776963
########## File path: flink-python/pyflink/table/table.py ########## @@ -106,6 +113,344 @@ def where(self, predicate): """ return Table(self._j_table.where(predicate)) + def group_by(self, fields): + """ + Groups the elements on some grouping keys. Use this before a selection with aggregations + to perform the aggregation on a per-group basis. Similar to a SQL GROUP BY statement. + + Example: + :: + >>> tab.group_by("key").select("key, value.avg") + + :param fields: Group keys. + :return: The grouped table. + """ + return GroupedTable(self._j_table.groupBy(fields)) + + def distinct(self): + """ + Removes duplicate values and returns onl + Example: + :: + >>> tab.select("key, value").distinct() + + :return: Result table. + """ + return Table(self._j_table.distinct()) + + def join(self, right, join_predicate=None): + """ + Joins two :class:`Table`s. Similar to a SQL join. The fields of the two joined + operations must not overlap, use :func:`~pyflink.table.Table.alias` to rename fields if + necessary. You can use where and select clauses after a join to further specify the + behaviour of the join. + + .. note:: + Both tables must be bound to the same :class:`TableEnvironment` . + + Example: + :: + >>> left.join(right).where("a = b && c > 3").select("a, b, d") + >>> left.join(right, "a = b") + + :param right: Right table. + :param join_predicate: Optional, the join predicate expression string. + :return: Result table. + """ + if join_predicate is not None: + return Table(self._j_table.join(right._j_table, join_predicate)) + else: + return Table(self._j_table.join(right._j_table)) + + def left_outer_join(self, right, join_predicate=None): + """ + Joins two :class:`Table`s. Similar to a SQL left outer join. The fields of the two joined + operations must not overlap, use :func:`~pyflink.table.Table.as_` to rename fields if + necessary. + + .. note:: + Both tables must be bound to the same :class:`TableEnvironment` and its + :class:`TableConfig` must have null check enabled (default). + + Example: + :: + >>> left.left_outer_join(right).select("a, b, d") + >>> left.left_outer_join(right, "a = b").select("a, b, d") + + :param right: Right table. + :param join_predicate: Optional, the join predicate expression string. + :return: Result table. + """ + if join_predicate is None: + return Table(self._j_table.leftOuterJoin(right._j_table)) + else: + return Table(self._j_table.leftOuterJoin( + right._j_table, join_predicate)) + + def right_outer_join(self, right, join_predicate): + """ + Joins two :class:`Table`s. Similar to a SQL right outer join. The fields of the two joined + operations must not overlap, use :func:`~pyflink.table.Table.as_` to rename fields if + necessary. + + .. note:: + Both tables must be bound to the same :class:`TableEnvironment` and its + :class:`TableConfig` must have null check enabled (default). + + Example: + :: + >>> left.right_outer_join(right, "a = b").select("a, b, d") + + :param right: Right table. + :param join_predicate: The join predicate expression string. + :return: Result table. + """ + return Table(self._j_table.rightOuterJoin( + right._j_table, join_predicate)) + + def full_outer_join(self, right, join_predicate): + """ + Joins two :class:`Table`s. Similar to a SQL full outer join. The fields of the two joined + operations must not overlap, use :func:`~pyflink.table.Table.as_` to rename fields if + necessary. + + .. note:: + Both tables must be bound to the same :class:`TableEnvironment` and its + :class:`TableConfig` must have null check enabled (default). + + Example: + :: + >>> left.full_outer_join(right, "a = b").select("a, b, d") + + :param right: Right table. + :param join_predicate: The join predicate expression string. + :return: Result table. + """ + return Table(self._j_table.fullOuterJoin( + right._j_table, join_predicate)) Review comment: Done. ---------------------------------------------------------------- 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