Skip to content

Commit

Permalink
[FLINK-21466][sql-client] Make "embedded" parameter optional when sta…
Browse files Browse the repository at this point in the history
…rt sql-client.sh

This closes apache#15255
  • Loading branch information
zck573693104 authored and wuchong committed Mar 20, 2021
1 parent 6540cb6 commit 7fad74d
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions docs/content.zh/docs/dev/table/sqlClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/dev/table/sqlClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion flink-end-to-end-tests/test-scripts/test_pyflink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}" \
Expand Down
4 changes: 2 additions & 2 deletions flink-end-to-end-tests/test-scripts/test_sql_client.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 1 addition & 1 deletion flink-end-to-end-tests/test-scripts/test_tpch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,21 @@ private void openCli(String sessionId, Executor executor) {
// --------------------------------------------------------------------------------------------

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();
Expand Down

0 comments on commit 7fad74d

Please sign in to comment.