dianfu commented on a change in pull request #11768: [FLINK-16943][python] 
Support set the configuration option "pipeline.jars" in PyFlink.
URL: https://github.com/apache/flink/pull/11768#discussion_r409515839
 
 

 ##########
 File path: flink-python/pyflink/table/tests/test_table_environment_api.py
 ##########
 @@ -329,6 +334,54 @@ def test_table_environment_with_blink_planner(self):
 
         self.assert_equals(results, ['2,hi,hello\n', '3,hello,hello\n'])
 
+    def test_set_jars(self):
+        jar_urls = []
+        func1_class_name = 
"org.apache.flink.table.planner.plan.stream.sql.Func1"
+        func2_class_name = "org.apache.flink.python.util.TestScalarFunction"
+        jar_urls.extend(self.validate_and_return_unloaded_jar_url(
+            func1_class_name,
+            
"flink-table/flink-table-planner-blink/target/flink-table-planner-blink*-tests.jar"))
+        jar_urls.extend(self.validate_and_return_unloaded_jar_url(
+            func2_class_name,
+            "flink-python/target/flink-python*-tests.jar"))
+
+        # test set the "pipeline.jars" multiple times
+        
self.t_env.get_config().get_configuration().set_string("pipeline.jars", 
";".join(jar_urls))
+        first_class_loader = 
get_gateway().jvm.Thread.currentThread().getContextClassLoader()
+
+        
self.t_env.get_config().get_configuration().set_string("pipeline.jars", 
jar_urls[0])
+        
self.t_env.get_config().get_configuration().set_string("pipeline.jars", 
";".join(jar_urls))
+        third_class_loader = 
get_gateway().jvm.Thread.currentThread().getContextClassLoader()
+
+        self.assertEqual(first_class_loader, third_class_loader)
+
+        source = self.t_env.from_elements([(1, "Hi"), (2, "Hello")], ["a", 
"b"])
+        self.t_env.register_java_function("func1", func1_class_name)
+        self.t_env.register_java_function("func2", func2_class_name)
+        table_sink = source_sink_utils.TestAppendSink(
+            ["a", "b"], [DataTypes.STRING(), DataTypes.STRING()])
+        self.t_env.register_table_sink("sink", table_sink)
+        source.select("func1(a.cast(int), b), func2(a.cast(int), 
b)").insert_into("sink")
+        self.t_env.execute("test")
+        actual = source_sink_utils.results()
+        expected = ['1 and Hi,1 or Hi', '2 and Hello,2 or Hello']
+        self.assert_equals(actual, expected)
+
+    def validate_and_return_unloaded_jar_url(self, func_class_name, 
jar_filename_pattern):
 
 Review comment:
   Split it into two methods to make it more clear?

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