dianfu commented on a change in pull request #9766: [FLINK-14018][python] Add 
Python building blocks to make sure the basic functionality of Python 
ScalarFunction could work
URL: https://github.com/apache/flink/pull/9766#discussion_r329335830
 
 

 ##########
 File path: flink-python/pyflink/table/udf.py
 ##########
 @@ -0,0 +1,217 @@
+################################################################################
+#  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.
+################################################################################
+import collections
+import functools
+import inspect
+from abc import ABCMeta, abstractmethod
+
+from pyflink.java_gateway import get_gateway
+from pyflink.table.types import DataType, _to_java_type
+from pyflink.util import utils
+
+__all__ = ['FunctionContext', 'ScalarFunction', 'udf']
+
+
+class FunctionContext(object):
+    """
+    Used to obtain global runtime information about the context in which the
+    user-defined function is executed. The information includes the metric 
group,
+    and global job parameters, etc.
+    """
+    pass
+
+
+class UserDefinedFunction(object):
+    """
+    Base interface for user-defined function.
+    """
+    __metaclass__ = ABCMeta
 
 Review comment:
   It's a best practice to declare the ABCMeta if it's an abstract class in 
Python. Quoted from 
[StackOverFlow](https://stackoverflow.com/questions/3570796/why-use-abstract-base-classes-in-python):
 "A handy feature of ABCs is that if you don't implement all necessary methods 
(and properties) you get an error upon instantiation, rather than an 
AttributeError, potentially much later, when you actually try to use the 
missing method.". I'll add a test case.

----------------------------------------------------------------
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