You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/10/27 09:26:53 UTC

[GitHub] [flink] dianfu commented on a change in pull request #13804: [FLINK-19233][python] Support distinct and filter keywords on Python UDAF

dianfu commented on a change in pull request #13804:
URL: https://github.com/apache/flink/pull/13804#discussion_r512515877



##########
File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/python/PythonAggregateFunctionInfo.java
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.functions.python;
+
+import org.apache.flink.annotation.Internal;
+
+/**
+ * PythonFunctionInfo contains the execution information of a Python aggregate function, such as:

Review comment:
       ```suggestion
    * PythonAggregateFunctionInfo contains the execution information of a Python aggregate function, such as:
   ```

##########
File path: flink-python/pyflink/fn_execution/aggregate.py
##########
@@ -297,6 +300,10 @@ def __init__(self,
             self._get_value_indexes.remove(index_of_count_star)
         self._udf_data_view_specs = udf_data_view_specs
         self._udf_data_views = []
+        self._filter_args = filter_args
+        self._distinct_mapping = distinct_mapping
+        self._distinct_view_reuse_descriptors = distinct_view_reuse_descriptors
+        self._distinct_data_view = {}

Review comment:
       ```suggestion
           self._distinct_data_views = {}
   ```

##########
File path: flink-python/pyflink/table/tests/test_aggregate.py
##########
@@ -358,6 +386,48 @@ def test_map_view_iterate(self):
                 ["Hi,Hi2,Hi3", "1,2,3", "Hi:3,Hi2:2,Hi3:1", 3, "hi"]],
                 columns=['a', 'b', 'c', 'd', 'e']))
 
+    def test_distinct_and_filter(self):
+        self.t_env.create_temporary_system_function(
+            "concat",
+            ConcatAggregateFunction())
+        self.t_env.get_config().get_configuration().set_string(

Review comment:
       What's the purpose to set these configuration explicitly in this test case?

##########
File path: flink-python/pyflink/fn_execution/aggregate.py
##########
@@ -287,7 +287,10 @@ def __init__(self,
                  udfs: List[AggregateFunction],
                  input_extractors: List,
                  index_of_count_star: int,
-                 udf_data_view_specs: List[List[DataViewSpec]]):
+                 udf_data_view_specs: List[List[DataViewSpec]],
+                 filter_args: List[int],
+                 distinct_mapping: List[int],
+                 distinct_view_reuse_descriptors: Dict[int, Tuple['function', List[int]]]):

Review comment:
       ```suggestion
                    distinct_view_descriptors: Dict[int, Tuple['function', List[int]]]):
   ```

##########
File path: flink-table/flink-table-common/src/main/java/org/apache/flink/table/functions/python/PythonAggregateFunctionInfo.java
##########
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.functions.python;
+
+import org.apache.flink.annotation.Internal;
+
+/**
+ * PythonFunctionInfo contains the execution information of a Python aggregate function, such as:
+ * the actual Python function, the input arguments, the filter arg, the distinct flag, etc.

Review comment:
       ```suggestion
    * the actual Python aggregation function, the input arguments, the filter arg, the distinct flag, etc.
   ```

##########
File path: flink-python/pyflink/fn_execution/operations.py
##########
@@ -285,23 +285,46 @@ def open(self):
     def generate_func(self, serialized_fn):
         user_defined_aggs = []
         input_extractors = []
+        filter_args = []
+        # stores which distinct view current function shared with
+        distinct_mapping = []

Review comment:
       ```suggestion
           distinct_view_indexes = []
   ```

##########
File path: flink-python/pyflink/fn_execution/aggregate.py
##########
@@ -287,7 +287,10 @@ def __init__(self,
                  udfs: List[AggregateFunction],
                  input_extractors: List,
                  index_of_count_star: int,
-                 udf_data_view_specs: List[List[DataViewSpec]]):
+                 udf_data_view_specs: List[List[DataViewSpec]],
+                 filter_args: List[int],
+                 distinct_mapping: List[int],

Review comment:
       ```suggestion
                    distinct_view_indexes: List[int],
   ```




----------------------------------------------------------------
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:
users@infra.apache.org