fsk119 commented on a change in pull request #16743:
URL: https://github.com/apache/flink/pull/16743#discussion_r686473967
##########
File path:
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
##########
@@ -389,51 +395,58 @@ private void validate(Operation operation, ExecutionMode
executionMode) {
private void callOperation(Operation operation, ExecutionMode mode) {
validate(operation, mode);
- if (operation instanceof QuitOperation) {
- // QUIT/EXIT
- callQuit();
- } else if (operation instanceof ClearOperation) {
- // CLEAR
- callClear();
- } else if (operation instanceof HelpOperation) {
- // HELP
- callHelp();
- } else if (operation instanceof SetOperation) {
- // SET
- callSet((SetOperation) operation);
- } else if (operation instanceof ResetOperation) {
- // RESET
- callReset((ResetOperation) operation);
- } else if (operation instanceof CatalogSinkModifyOperation) {
- // INSERT INTO/OVERWRITE
- callInsert((CatalogSinkModifyOperation) operation);
- } else if (operation instanceof QueryOperation) {
- // SELECT
- callSelect((QueryOperation) operation);
- } else if (operation instanceof ExplainOperation) {
- // EXPLAIN
- callExplain((ExplainOperation) operation);
- } else if (operation instanceof BeginStatementSetOperation) {
- // BEGIN STATEMENT SET
- callBeginStatementSet();
- } else if (operation instanceof EndStatementSetOperation) {
- // END
- callEndStatementSet();
- } else if (operation instanceof AddJarOperation) {
- // ADD JAR
- callAddJar((AddJarOperation) operation);
- } else if (operation instanceof RemoveJarOperation) {
- // REMOVE JAR
- callRemoveJar((RemoveJarOperation) operation);
- } else if (operation instanceof ShowJarsOperation) {
- // SHOW JARS
- callShowJars();
- } else if (operation instanceof ShowCreateTableOperation) {
- // SHOW CREATE TABLE
- callShowCreateTable((ShowCreateTableOperation) operation);
- } else {
- // fallback to default implementation
- executeOperation(operation);
+ final Thread thread = Thread.currentThread();
Review comment:
How about move the logic about register handler to the
`executeStatement` part. We may add more commands in the future and the block
will be larger and lager.
```
operation.ifPresent(
op -> {
final Thread thread = Thread.currentThread();
final Terminal.SignalHandler previousHandler =
terminal.handle(
Terminal.Signal.INT, (signal) ->
thread.interrupt());
try {
callOperation(op, executionMode);
} finally {
if (previousHandler != null) {
terminal.handle(Terminal.Signal.INT,
previousHandler);
}
}
});
```
##########
File path:
flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliClient.java
##########
@@ -324,7 +325,12 @@ private boolean executeStatement(String statement,
ExecutionMode executionMode)
final Optional<Operation> operation = parseCommand(statement);
operation.ifPresent(op -> callOperation(op, executionMode));
} catch (SqlExecutionException e) {
- printExecutionException(e);
+ Throwable t = ExceptionUtils.getRootCause(e);
+ if (t instanceof InterruptedException) {
+ printExecutionException(t);
+ } else {
+ printExecutionException(e);
+ }
Review comment:
Maybe we don't need do this. In non-verbose mode, we will only print the
root of the exception.
--
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]