From 5d2c2f7c68abcdaac1e02169aaed11ef5f404921 Mon Sep 17 00:00:00 2001 From: praveenkrishna Date: Mon, 2 Sep 2019 16:07:09 +0530 Subject: [PATCH] Respect empty --execute argument --- presto-cli/src/main/java/io/prestosql/cli/Console.java | 2 +- .../java/io/prestosql/tests/cli/PrestoCliTests.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/presto-cli/src/main/java/io/prestosql/cli/Console.java b/presto-cli/src/main/java/io/prestosql/cli/Console.java index 7e7c0ddb98182..8af69128a43c8 100644 --- a/presto-cli/src/main/java/io/prestosql/cli/Console.java +++ b/presto-cli/src/main/java/io/prestosql/cli/Console.java @@ -86,7 +86,7 @@ public class Console public boolean run() { ClientSession session = clientOptions.toClientSession(); - boolean hasQuery = !isNullOrEmpty(clientOptions.execute); + boolean hasQuery = clientOptions.execute != null; boolean isFromFile = !isNullOrEmpty(clientOptions.file); if (!hasQuery && !isFromFile) { diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoCliTests.java b/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoCliTests.java index 2cb274f8dbd8c..5cc3dedc96e13 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoCliTests.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoCliTests.java @@ -40,6 +40,7 @@ import static java.util.stream.Collectors.toList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.testng.Assert.assertTrue; public class PrestoCliTests extends PrestoCliLauncher @@ -125,6 +126,15 @@ public void shouldRunBatchQuery() presto.waitForWithTimeoutAndKill(); } + @Test(groups = CLI, timeOut = TIMEOUT) + public void shouldExecuteEmptyListOfStatements() + throws Exception + { + launchPrestoCliWithServerArgument("--execute", ""); + assertTrue(trimLines(presto.readRemainingOutputLines()).isEmpty()); + presto.waitForWithTimeoutAndKill(); + } + @Test(groups = CLI, timeOut = TIMEOUT) public void shouldUseCatalogAndSchemaOptions() throws Exception