Skip to content

Commit

Permalink
Revert "[KYUUBI apache#6526] Kyuubi BeeLine wrongly process JDBC URL …
Browse files Browse the repository at this point in the history
…that contains `--`"

This reverts commit e26b57a.
  • Loading branch information
pan3793 committed Jul 8, 2024
1 parent e26b57a commit 53b3911
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ protected void processOption(String arg, ListIterator iter) throws ParseExceptio
if (!commands.isEmpty()) {
for (String command : commands) {
debug(loc("executing-command", command));
if (!removeCommentsDispatch(command)) {
if (!dispatch(command)) {
code++;
}
}
Expand Down Expand Up @@ -282,8 +282,9 @@ int runInit() {
return executionResult;
}

// see HIVE-15820: comment at the head of beeline -e only dispatch commands
boolean removeCommentsDispatch(String line) {
// see HIVE-15820: comment at the head of beeline -e
@Override
boolean dispatch(String line) {
return super.dispatch(isPythonMode() ? line : HiveStringUtils.removeComments(line));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,12 @@ public void testKyuubiBeeLinePythonMode() {

@Test
public void testKyuubiBeelineComment() {
String[] url = new String[] {""};
KyuubiBeeLine interceptedKyuubiBeeLine =
new KyuubiBeeLine() {
@Override
boolean dispatch(String line) {
if (line != null && line.startsWith("!connect")) {
LOG.info("Return true for command: {} to pretend connection is established.", line);
url[0] = line;
return true;
}
return super.dispatch(line);
Expand All @@ -124,27 +122,19 @@ public boolean sql(String line, boolean entireLineAsCommand) {
interceptedKyuubiBeeLine.initArgs(
new String[] {"-u", "dummy_url", "-e", "--comment show database;"});
assertEquals(0, cmd[0].length());
assertEquals("!connect dummy_url '' '' ", url[0]);

// Beeline#exit must be false to execute sql
interceptedKyuubiBeeLine.setExit(false);
interceptedKyuubiBeeLine.initArgs(
new String[] {"-u", "dummy_url", "-e", "--comment\n show database;"});
assertEquals("show database;", cmd[0]);
assertEquals("!connect dummy_url '' '' ", url[0]);

interceptedKyuubiBeeLine.setExit(false);
interceptedKyuubiBeeLine.initArgs(
new String[] {
"-u", "dummy_url", "-e", "--comment line 1 \n --comment line 2 \n show database;"
});
assertEquals("show database;", cmd[0]);

interceptedKyuubiBeeLine.setExit(false);
interceptedKyuubiBeeLine.initArgs(
new String[] {"-u", "dummy--url", "-e", "--comment\n show database;"});
assertEquals("show database;", cmd[0]);
assertEquals("!connect dummy--url '' '' ", url[0]);
}

static class BufferPrintStream extends PrintStream {
Expand Down

0 comments on commit 53b3911

Please sign in to comment.