-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-20320][sql-client] support init sql file in sql client #15437
Conversation
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit 3ff81e4 (Sat Aug 28 11:12:45 UTC 2021) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
Outdated
Show resolved
Hide resolved
@@ -124,6 +125,22 @@ private void openCli(String sessionId, Executor executor) { | |||
} | |||
|
|||
boolean isInteractiveMode = !hasSqlFile && !hasUpdateStatement; | |||
if (hasInitFile) { | |||
boolean success = | |||
CliClient.initializeSession( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why init client here instead of after you created the real cli client?
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
Outdated
Show resolved
Hide resolved
public CliClient( | ||
Terminal terminal, | ||
CliClient( | ||
@Nullable Terminal terminal, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary to pass a nullable terminal here.
The class field this.terminal
will naturally be NULL
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
Outdated
Show resolved
Hide resolved
@@ -97,9 +102,9 @@ | |||
|
|||
private final String sessionId; | |||
|
|||
private final Terminal terminal; | |||
private @Nullable Terminal terminal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary Nullable
you can also re-organize the class fields, move this one below to all the final ones
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some final comments.
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/SqlClient.java
Outdated
Show resolved
Hide resolved
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, verified locally and the timeout issue seems fixed.
What is the purpose of the change
Support to start the sql client with -i init file.
If the execution get error, the sql client will stop and exit. But currently we print the error message to the LOG not console. The idea is from the HIVE.
Brief change log
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: (yes / no)Documentation