fsk119 commented on code in PR #21725:
URL: https://github.com/apache/flink/pull/21725#discussion_r1080884303


##########
flink-connectors/flink-connector-hive/pom.xml:
##########
@@ -1097,6 +1097,12 @@ under the License.
                        <version>${project.version}</version>
                        <scope>test</scope>
                </dependency>
+               <dependency>

Review Comment:
   Why add python dependencies here?



##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/context/DefaultContext.java:
##########
@@ -55,15 +58,31 @@ public DefaultContext(Configuration flinkConfig, 
List<CustomCommandLine> command
                 flinkConfig, 
PluginUtils.createPluginManagerFromRootFolder(flinkConfig));
 
         Options commandLineOptions = collectCommandLineOptions(commandLines);
+
+        final List<URL> dependencies = new ArrayList<>();
+        // add python dependencies by default
+        try {
+            URL location =
+                    Class.forName(
+                                    
"org.apache.flink.python.PythonFunctionRunner",
+                                    false,
+                                    
Thread.currentThread().getContextClassLoader())
+                            .getProtectionDomain()
+                            .getCodeSource()
+                            .getLocation();
+            if (Paths.get(location.toURI()).toFile().isFile()) {
+                dependencies.add(location);
+            }
+        } catch (URISyntaxException | ClassNotFoundException e) {
+            throw new SqlExecutionException("Failed to find flink-python 
jar.", e);

Review Comment:
    throw SqlGatewayException. In the `SqlGateway#startSqlGateway`, we will 
notice users it's a bug if the type of the exception is not SqlGatewayException.



##########
flink-table/flink-sql-gateway/src/main/java/org/apache/flink/table/gateway/service/context/DefaultContext.java:
##########
@@ -55,15 +58,31 @@ public DefaultContext(Configuration flinkConfig, 
List<CustomCommandLine> command
                 flinkConfig, 
PluginUtils.createPluginManagerFromRootFolder(flinkConfig));
 
         Options commandLineOptions = collectCommandLineOptions(commandLines);
+
+        final List<URL> dependencies = new ArrayList<>();
+        // add python dependencies by default
+        try {
+            URL location =
+                    Class.forName(
+                                    
"org.apache.flink.python.PythonFunctionRunner",
+                                    false,
+                                    
Thread.currentThread().getContextClassLoader())
+                            .getProtectionDomain()
+                            .getCodeSource()
+                            .getLocation();
+            if (Paths.get(location.toURI()).toFile().isFile()) {
+                dependencies.add(location);
+            }
+        } catch (URISyntaxException | ClassNotFoundException e) {
+            throw new SqlExecutionException("Failed to find flink-python 
jar.", e);

Review Comment:
   Can we move this code block to `DefaultContext#load`? I think we will 
introduce -l/-j comand line paramters in the future.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to