You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by am...@apache.org on 2025/09/02 11:59:34 UTC
(ignite-3) 02/03: Fix SqlCommand
This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch ignite-26156
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 7101de5c2eeda4abbcfdcbadd5975ec3b8e8ac34
Author: amashenkov <am...@apache.org>
AuthorDate: Tue Sep 2 11:07:02 2025 +0300
Fix SqlCommand
---
.../internal/cli/commands/sql/SqlCommand.java | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlCommand.java b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlCommand.java
index 3cb6f3d1b6f..c393e85ec2f 100644
--- a/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlCommand.java
+++ b/modules/cli/src/main/java/org/apache/ignite/internal/cli/commands/sql/SqlCommand.java
@@ -56,14 +56,19 @@ import picocli.CommandLine.Parameters;
description = "Executes SQL query"
)
public class SqlCommand extends BaseCommand implements Callable<Integer> {
- @Option(names = JDBC_URL_OPTION, required = true, descriptionKey = JDBC_URL_KEY, description = JDBC_URL_OPTION_DESC)
- private String jdbc;
+ @ArgGroup(validate = false, exclusive = false)
+ private JdbcOption jdbcOption;
- @Option(names = PLAIN_OPTION, description = PLAIN_OPTION_DESC)
- private boolean plain;
+ private static class JdbcOption {
+ @Option(names = JDBC_URL_OPTION, required = true, descriptionKey = JDBC_URL_KEY, description = JDBC_URL_OPTION_DESC)
+ private String jdbc;
- @ArgGroup(multiplicity = "1")
- private ExecOptions execOptions;
+ @Option(names = PLAIN_OPTION, description = PLAIN_OPTION_DESC)
+ private boolean plain;
+
+ @ArgGroup(multiplicity = "1")
+ private ExecOptions execOptions;
+ }
private static class ExecOptions {
@Parameters(index = "0", description = "SQL query to execute")
@@ -86,12 +91,13 @@ public class SqlCommand extends BaseCommand implements Callable<Integer> {
*/
@Override
public Integer call() {
- try (SqlManager sqlManager = new SqlManager(jdbc)) {
+ try (SqlManager sqlManager = new SqlManager(jdbcOption.jdbc)) {
+ ExecOptions execOptions = jdbcOption.execOptions;
String executeCommand = execOptions.file != null ? extract(execOptions.file) : execOptions.command;
return runPipeline(CallExecutionPipeline.builder(new SqlQueryCall(sqlManager))
.inputProvider(() -> new StringCallInput(executeCommand))
.exceptionHandler(SqlExceptionHandler.INSTANCE)
- .decorator(new SqlQueryResultDecorator(plain))
+ .decorator(new SqlQueryResultDecorator(jdbcOption.plain))
);
} catch (SQLException e) {
ExceptionWriter exceptionWriter = ExceptionWriter.fromPrintWriter(spec.commandLine().getErr());