dianfu commented on a change in pull request #9858: [FLINK-14208][python] 
Optimize Python UDFs with parameters of constant values
URL: https://github.com/apache/flink/pull/9858#discussion_r333370109
 
 

 ##########
 File path: flink-python/pyflink/table/tests/test_udf.py
 ##########
 @@ -96,6 +96,89 @@ def test_udf_in_join_condition(self):
         actual = source_sink_utils.results()
         self.assert_equals(actual, ["2,Hi,2,Flink"])
 
+    def test_udf_with_constant_param(self):
+        def func_constant_param(p, null_param, tinyint_param, smallint_param, 
int_param,
+                                bigint_param, decimal_param, float_param, 
double_param,
+                                boolean_param, str_param,
+                                date_param, time_param, timestamp_param):
+            from decimal import Decimal
+            import datetime
+            if null_param is None:
+                p += 1
+
+            if isinstance(tinyint_param, int):
+                p += tinyint_param
+            if isinstance(smallint_param, int):
+                p += smallint_param
+            if isinstance(int_param, int):
+                p += int_param
+            if isinstance(bigint_param, int):
+                p += bigint_param
+            if isinstance(decimal_param, Decimal):
+                p += int(decimal_param)
+            if isinstance(float_param, float):
+                p += int(float_param)
+            if isinstance(double_param, float):
+                p += float(double_param)
+
+            if boolean_param is True:
+                p += 1
+
+            p += len(str_param)
+
+            if date_param == datetime.date(year=2014, month=9, day=13):
 
 Review comment:
   Same as above, throw an exception if the value is not expected.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to