This is an automated email from the ASF dual-hosted git repository.

jark pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 7fad74dba80d2fea74aa30a1cfa3cadbe6df13ed
Author: zck <[email protected]>
AuthorDate: Wed Mar 17 23:22:21 2021 +0800

    [FLINK-21466][sql-client] Make "embedded" parameter optional when start 
sql-client.sh
    
    This closes #15255
---
 docs/content.zh/docs/dev/table/sqlClient.md            |  6 +++---
 docs/content/docs/dev/table/sqlClient.md               |  4 ++--
 flink-end-to-end-tests/test-scripts/test_pyflink.sh    |  2 +-
 flink-end-to-end-tests/test-scripts/test_sql_client.sh |  4 ++--
 flink-end-to-end-tests/test-scripts/test_tpch.sh       |  2 +-
 .../java/org/apache/flink/table/client/SqlClient.java  | 18 ++++++++++++------
 6 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/docs/content.zh/docs/dev/table/sqlClient.md 
b/docs/content.zh/docs/dev/table/sqlClient.md
index 08a0831..48a5fe8 100644
--- a/docs/content.zh/docs/dev/table/sqlClient.md
+++ b/docs/content.zh/docs/dev/table/sqlClient.md
@@ -47,10 +47,10 @@ SQL 客户端捆绑在常规 Flink 发行版中,因此可以直接运行。它
 
 ### 启动 SQL 客户端命令行界面
 
-SQL Client 脚本也位于 Flink 的 bin 
目录中。[将来](sqlClient.html#limitations--future),用户可以通过启动嵌入式 standalone 进程或通过连接到远程 
SQL 客户端网关来启动 SQL 客户端命令行界面。目前仅支持 `embedded` 模式。可以通过以下方式启动 CLI:
+SQL Client 脚本也位于 Flink 的 bin 
目录中。[将来](sqlClient.html#limitations--future),用户可以通过启动嵌入式 standalone 进程或通过连接到远程 
SQL 客户端网关来启动 SQL 客户端命令行界面。目前仅支持 `embedded`,模式默认值`embedded`。可以通过以下方式启动 CLI:
 
 ```bash
-./bin/sql-client.sh embedded
+./bin/sql-client.sh
 ```
 
 默认情况下,SQL 客户端将从 `./conf/sql-client-defaults.yaml` 
中读取配置。有关环境配置文件结构的更多信息,请参见[配置部分](sqlClient.html#environment-files)。
@@ -158,7 +158,7 @@ Received a total of 5 rows
 SQL 客户端启动时可以添加 CLI 选项,具体如下。
 
 ```text
-./bin/sql-client.sh embedded --help
+./bin/sql-client.sh --help
 
 Mode "embedded" submits Flink jobs from the local machine.
 
diff --git a/docs/content/docs/dev/table/sqlClient.md 
b/docs/content/docs/dev/table/sqlClient.md
index 025a132..0f8111d 100644
--- a/docs/content/docs/dev/table/sqlClient.md
+++ b/docs/content/docs/dev/table/sqlClient.md
@@ -48,10 +48,10 @@ The SQL Client is bundled in the regular Flink distribution 
and thus runnable ou
 
 ### Starting the SQL Client CLI
 
-The SQL Client scripts are also located in the binary directory of Flink. [In 
the future](sqlClient.html#limitations--future), a user will have two 
possibilities of starting the SQL Client CLI either by starting an embedded 
standalone process or by connecting to a remote SQL Client Gateway. At the 
moment only the `embedded` mode is supported. You can start the CLI by calling:
+The SQL Client scripts are also located in the binary directory of Flink. [In 
the future](sqlClient.html#limitations--future), a user will have two 
possibilities of starting the SQL Client CLI either by starting an embedded 
standalone process or by connecting to a remote SQL Client Gateway. At the 
moment only the `embedded` mode is supported, and default mode is `embedded`. 
You can start the CLI by calling:
 
 ```bash
-./bin/sql-client.sh embedded
+./bin/sql-client.sh
 ```
 
 By default, the SQL Client will read its configuration from the environment 
file located in `./conf/sql-client-defaults.yaml`. See the [configuration 
part](sqlClient.html#environment-files) for more information about the 
structure of environment files.
diff --git a/flink-end-to-end-tests/test-scripts/test_pyflink.sh 
b/flink-end-to-end-tests/test-scripts/test_pyflink.sh
index 15920e8..20c4e74 100755
--- a/flink-end-to-end-tests/test-scripts/test_pyflink.sh
+++ b/flink-end-to-end-tests/test-scripts/test_pyflink.sh
@@ -198,7 +198,7 @@ EOF
 
 SQL_STATEMENT="insert into sink select add_one(a) from (VALUES (1), (2), (3)) 
as source (a)"
 
-JOB_ID=$($FLINK_DIR/bin/sql-client.sh embedded \
+JOB_ID=$($FLINK_DIR/bin/sql-client.sh \
   --environment $SQL_CONF \
   -pyfs "${FLINK_PYTHON_TEST_DIR}/python/add_one.py" \
   -pyreq "${REQUIREMENTS_PATH}" \
diff --git a/flink-end-to-end-tests/test-scripts/test_sql_client.sh 
b/flink-end-to-end-tests/test-scripts/test_sql_client.sh
index 37bbd38..2ccd377 100755
--- a/flink-end-to-end-tests/test-scripts/test_sql_client.sh
+++ b/flink-end-to-end-tests/test-scripts/test_sql_client.sh
@@ -231,7 +231,7 @@ INSERT INTO ElasticsearchUpsertSinkTable
 EOF
 )
 
-JOB_ID=$($FLINK_DIR/bin/sql-client.sh embedded \
+JOB_ID=$($FLINK_DIR/bin/sql-client.sh \
   --jar $KAFKA_SQL_JAR \
   --jar $ELASTICSEARCH_SQL_JAR \
   --jar $SQL_TOOLBOX_JAR \
@@ -259,7 +259,7 @@ INSERT INTO ElasticsearchAppendSinkTable
 EOF
 )
 
-JOB_ID=$($FLINK_DIR/bin/sql-client.sh embedded \
+JOB_ID=$($FLINK_DIR/bin/sql-client.sh \
   --jar $KAFKA_SQL_JAR \
   --jar $ELASTICSEARCH_SQL_JAR \
   --jar $SQL_TOOLBOX_JAR \
diff --git a/flink-end-to-end-tests/test-scripts/test_tpch.sh 
b/flink-end-to-end-tests/test-scripts/test_tpch.sh
index cb52222..f2416c1 100755
--- a/flink-end-to-end-tests/test-scripts/test_tpch.sh
+++ b/flink-end-to-end-tests/test-scripts/test_tpch.sh
@@ -83,7 +83,7 @@ EOF
         SQL_STATEMENT="INSERT INTO q$i $(cat "$ORIGIN_QUERY_DIR/q$i.sql")"
     fi
 
-    JOB_ID=$("$FLINK_DIR/bin/sql-client.sh" embedded \
+    JOB_ID=$("$FLINK_DIR/bin/sql-client.sh" \
         --environment "$SQL_CONF" \
         --update "$SQL_STATEMENT" | grep "Job ID:" | sed 's/.* //g')
 
diff --git 
a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
 
b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
index 3fc822d..9e6a4f3 100644
--- 
a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
+++ 
b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
@@ -125,15 +125,21 @@ public class SqlClient {
     // 
--------------------------------------------------------------------------------------------
 
     public static void main(String[] args) {
-        if (args.length < 1) {
-            CliOptionsParser.printHelpClient();
-            return;
+        final String model;
+        final String[] modeArgs;
+        if (args.length < 1 || args[0].startsWith("-")) {
+            // mode is not specified, use the default `embedded` mode
+            model = MODE_EMBEDDED;
+            modeArgs = args;
+        } else {
+            // mode is specified, extract the mode value and reaming args
+            model = args[0];
+            // remove mode
+            modeArgs = Arrays.copyOfRange(args, 1, args.length);
         }
 
-        switch (args[0]) {
+        switch (model) {
             case MODE_EMBEDDED:
-                // remove mode
-                final String[] modeArgs = Arrays.copyOfRange(args, 1, 
args.length);
                 final CliOptions options = 
CliOptionsParser.parseEmbeddedModeClient(modeArgs);
                 if (options.isPrintHelp()) {
                     CliOptionsParser.printHelpEmbeddedModeClient();

Reply via email to