This is an automated email from the ASF dual-hosted git repository.

feiwang pushed a commit to branch branch-1.7
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/branch-1.7 by this push:
     new fadb802d3 [KYUUBI #4619] Fix beeline with -e When there are other SQL 
statements before the source statement, the source statement cannot be executed 
normally
fadb802d3 is described below

commit fadb802d314431b0b8bf4b32a1419d2b0b80160f
Author: xu.guo <[email protected]>
AuthorDate: Tue Apr 4 09:36:05 2023 +0800

    [KYUUBI #4619] Fix beeline with -e When there are other SQL statements 
before the source statement, the source statement cannot be executed normally
    
    ### _Why are the changes needed?_
    
    When using beeline -e, if there is a newline or space between the source 
statement and the previous sql, the source statement will be misjudged as a sql 
statement and sent to the server for execution
    
![image](https://user-images.githubusercontent.com/20243868/227915694-42445ecb-7d0e-4ebe-8e8c-b2a25fe069a1.png)
    
    
![image](https://user-images.githubusercontent.com/20243868/227915440-fcc540d8-a265-4050-82de-3ffa25c7abc2.png)
    
    ### _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
    
    - [ ] [Run 
test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests)
 locally before make a pull request
    
    Closes #4619 from thomasg19930417/master.
    
    Closes #4619
    
    a2bfc0f0a [xu.guo] Fix When there are other sql before the source 
statement, the source statement cannot be executed normally
    1ec0b8124 [xu.guo] Fix When there are other sql before the source 
statement, the source statement cannot be executed normally
    9abba3cf5 [thomasgx] Merge branch 'apache:master' into master
    f8405eb93 [Cheng Pan] Update 
kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java
    3ad46c1d6 [Cheng Pan] Update 
kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java
    31fa80771 [xu.guo] Merge branch 'master' of 
https://github.com/thomasg19930417/kyuubi
    41e090d66 [thomasgx] Merge branch 'apache:master' into master
    ba82229a8 [xu.guo] Move initializeConsoleReader to KyuubiCommands#connect
    e06927b78 [xu.guo] Replace create new  consoleReader instance with  call 
initializeConsoleReader
    86f2e5078 [xu.guo] Fix code style
    b0c472229 [xu.guo] Fix Beeline with -i run sql faild
    042987aa6 [xu.guo] Fix Beeline with -i run sql faild
    
    Lead-authored-by: xu.guo <[email protected]>
    Co-authored-by: thomasgx <[email protected]>
    Co-authored-by: Cheng Pan <[email protected]>
    Signed-off-by: fwang12 <[email protected]>
    (cherry picked from commit d7c1c94f23af5c9b37be2ea298e22bb5e63ae35f)
    Signed-off-by: fwang12 <[email protected]>
---
 .../src/main/java/org/apache/hive/beeline/KyuubiCommands.java           | 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java 
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java
index 311cb6a95..9ce4cb6f7 100644
--- 
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java
+++ 
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiCommands.java
@@ -54,12 +54,14 @@ public class KyuubiCommands extends Commands {
   }
 
   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());
 

Reply via email to