Skip to content

Commit

Permalink
Fix When there are other sql before the source statement, the source …
Browse files Browse the repository at this point in the history
…statement cannot be executed normally
  • Loading branch information
thomasg19930417 committed Mar 27, 2023
1 parent 9abba3c commit 1ec0b81
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.sql.*;
import java.util.*;
import org.apache.hive.beeline.logs.KyuubiBeelineInPlaceUpdateStream;
import org.apache.hive.common.util.HiveStringUtils;
import org.apache.kyuubi.jdbc.hive.KyuubiStatement;
import org.apache.kyuubi.jdbc.hive.Utils;
import org.apache.kyuubi.jdbc.hive.logs.InPlaceUpdateStream;
Expand Down Expand Up @@ -54,12 +55,14 @@ private String[] tokenizeCmd(String cmd) {
}

private boolean isSourceCMD(String cmd) {
cmd = cmd.trim();
if (cmd == null || cmd.isEmpty()) return false;
String[] tokens = tokenizeCmd(cmd);
return tokens[0].equalsIgnoreCase("source");
}

private boolean sourceFile(String cmd) {
cmd = cmd.trim();
String[] tokens = tokenizeCmd(cmd);
String cmd_1 = getFirstCmd(cmd, tokens[0].length());

Expand Down Expand Up @@ -505,7 +508,7 @@ public boolean connect(Properties props) throws IOException {

@Override
public String handleMultiLineCmd(String line) throws IOException {
int[] startQuote = {-1};
line = HiveStringUtils.removeComments(line);
Character mask =
(System.getProperty("jline.terminal", "").equals("jline.UnsupportedTerminal"))
? null
Expand Down Expand Up @@ -536,7 +539,8 @@ public String handleMultiLineCmd(String line) throws IOException {
if (extra == null) { // it happens when using -f and the line of cmds does not end with ;
break;
}
if (!extra.isEmpty()) {
extra = HiveStringUtils.removeComments(extra);
if (extra != null && !extra.isEmpty()) {
line += "\n" + extra;
}
}
Expand Down

0 comments on commit 1ec0b81

Please sign in to comment.