fsk119 commented on a change in pull request #16028:
URL: https://github.com/apache/flink/pull/16028#discussion_r642749501



##########
File path: 
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlExecutionException.java
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.client;
+
+/** Exception thrown during the execution of SQL statements. */
+public class SqlExecutionException extends RuntimeException {

Review comment:
       I think `SqlClientException` is enough.

##########
File path: 
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
##########
@@ -213,6 +214,16 @@ protected static void startClient(String[] args, 
Supplier<Terminal> terminalFact
         }
     }
 
+    public static void checkArgs(String[] args) {
+        for (String arg : args) {
+            if (arg.trim().toLowerCase().startsWith("hdfs")) {

Review comment:
       It have other protocols, e.g. oss. Would better to check the protocol  
whether is "file". Also I think the validation should be like 
   
   ```
       public static void checkFilePath(String filePath) {
           Path path = new Path(filePath);
           String scheme = path.toUri().getScheme();
           if (scheme != null && !scheme.equals("file")) {
               throw new SqlClientException("SQL Client only supports to load 
files in local.");
           }
       }
   ```
   
   Please add the check around the 
[validation](https://github.com/apache/flink/blob/master/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java#L123)
 here.

##########
File path: 
flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/SqlClientTest.java
##########
@@ -205,6 +205,17 @@ public void testExecuteSqlFile() throws Exception {
         }
     }
 
+    @Test
+    public void testExecuteSqlWithHDFSFile() throws Exception {
+        List<String> statements = Collections.singletonList("HELP;\n");
+        String sqlFilePath = createSqlFile(statements, "test-sql.sql");
+        String[] args = new String[] {"-f", "hdfs:/" + sqlFilePath};

Review comment:
       Just use a invalid file path is enough. We don't need to create a new 
file here.
   
   Should be `"hdfs://path/to/file"`?




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


Reply via email to