Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions presto-cli/src/main/java/com/facebook/presto/cli/Console.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public boolean run()
Optional.ofNullable(clientOptions.krb5CredentialCachePath),
!clientOptions.krb5DisableRemoteServiceHostnameCanonicalization)) {
if (hasQuery) {
return executeCommand(queryRunner, query, clientOptions.outputFormat, clientOptions.ignoreErrors);
return executeCommand(queryRunner, query, clientOptions.outputFormat, clientOptions.ignoreErrors, clientOptions.debug);
}

runConsole(queryRunner, exiting);
Expand Down Expand Up @@ -253,7 +253,7 @@ private static void runConsole(QueryRunner queryRunner, AtomicBoolean exiting)
outputFormat = OutputFormat.VERTICAL;
}

process(queryRunner, split.statement(), outputFormat, tableNameCompleter::populateCache, true);
process(queryRunner, split.statement(), outputFormat, tableNameCompleter::populateCache, true, System.out);
reader.getHistory().add(squeezeStatement(split.statement()) + split.terminator());
}

Expand All @@ -270,13 +270,13 @@ private static void runConsole(QueryRunner queryRunner, AtomicBoolean exiting)
}
}

private static boolean executeCommand(QueryRunner queryRunner, String query, OutputFormat outputFormat, boolean ignoreErrors)
private static boolean executeCommand(QueryRunner queryRunner, String query, OutputFormat outputFormat, boolean ignoreErrors, boolean interactive)
{
boolean success = true;
StatementSplitter splitter = new StatementSplitter(query);
for (Statement split : splitter.getCompleteStatements()) {
if (!isEmptyStatement(split.statement())) {
if (!process(queryRunner, split.statement(), outputFormat, () -> {}, false)) {
if (!process(queryRunner, split.statement(), outputFormat, () -> {}, interactive, System.err)) {
if (!ignoreErrors) {
return false;
}
Expand All @@ -291,7 +291,7 @@ private static boolean executeCommand(QueryRunner queryRunner, String query, Out
return success;
}

private static boolean process(QueryRunner queryRunner, String sql, OutputFormat outputFormat, Runnable schemaChanged, boolean interactive)
private static boolean process(QueryRunner queryRunner, String sql, OutputFormat outputFormat, Runnable schemaChanged, boolean interactive, PrintStream printStream)
{
String finalSql;
try {
Expand All @@ -309,7 +309,7 @@ private static boolean process(QueryRunner queryRunner, String sql, OutputFormat
}

try (Query query = queryRunner.startQuery(finalSql)) {
boolean success = query.renderOutput(System.out, outputFormat, interactive);
boolean success = query.renderOutput(printStream, outputFormat, interactive);

ClientSession session = queryRunner.getSession();

Expand Down