[KYUUBI #4006] Fix the incorrect execution of the source command

### _Why are the changes needed?_

close #4006

refer 7c343471aa/beeline/src/java/org/apache/hive/beeline/Commands.java (L856)

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

Successfully executed after fix:
![image](https://user-images.githubusercontent.com/17894939/208376659-fc5e5a2f-bec6-416e-a8e5-74082c70f24b.png)

- [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #4007 from wForget/KYUUBI-4006.

Closes #4006

0a9710503 [wForget] Fix comment extra never reads next line
47b30247f [wForget] [KYUUBI-4006] Fix the incorrect execution of the source command

Authored-by: wForget <643348094@qq.com>
Signed-off-by: fwang12 <fwang12@ebay.com>
This commit is contained in:
wForget 2022-12-20 20:49:37 +08:00 committed by fwang12
parent 14faff24b3
commit a494aa9b87

View File

@ -45,7 +45,7 @@ public class KyuubiCommands extends Commands {
/** Extract and clean up the first command in the input. */
private String getFirstCmd(String cmd, int length) {
return cmd.substring(length);
return cmd.substring(length).trim();
}
private String[] tokenizeCmd(String cmd) {
@ -82,9 +82,8 @@ public class KyuubiCommands extends Commands {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(sourceFile));
String extra = reader.readLine();
String lines = null;
while (extra != null) {
String lines = null, extra;
while ((extra = reader.readLine()) != null) {
if (beeLine.isComment(extra)) {
continue;
}
@ -93,7 +92,6 @@ public class KyuubiCommands extends Commands {
} else {
lines += "\n" + extra;
}
extra = reader.readLine();
}
String[] cmds = lines.split(";");
for (String c : cmds) {