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

chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new e26b57acd [KYUUBI #6526] Kyuubi BeeLine wrongly process JDBC URL that 
contains `--`
e26b57acd is described below

commit e26b57acda1d36a1cbfe07c105e24c1b0d18d2ce
Author: axiangzheng <[email protected]>
AuthorDate: Mon Jul 8 14:17:40 2024 +0800

    [KYUUBI #6526] Kyuubi BeeLine wrongly process JDBC URL that contains `--`
    
    # :mag: Description
    ## Issue References ๐Ÿ”—
    
    This pull request fixes https://github.com/apache/kyuubi/issues/6522
    
    ## Describe Your Solution ๐Ÿ”ง
    
    Remove comments in dispatch commands only execute command
    
    ## Types of changes :bookmark:
    
    - [ ] Bugfix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
    
    ## Test Plan ๐Ÿงช
    
    #### Behavior Without This Pull Request :coffin:
    
    #### Behavior With This Pull Request :tada:
    
    #### Related Unit Tests
    
    ---
    
    # Checklist ๐Ÿ“
    
    - [ ] This patch was not authored or co-authored using [Generative 
Tooling](https://www.apache.org/legal/generative-tooling.html)
    
    **Be nice. Be informative.**
    
    Closes #6526 from zcx513566/issues_6522.
    
    Closes #6526
    
    3dfd94364 [axiangzheng] [Bug] Use kyuubi beeline connect kyuubi server 
error if url contains '--' string
    6677497ee [axiangzheng] [Bug] Use kyuubi beeline connect kyuubi server 
error if url contains '--' string
    
    Authored-by: axiangzheng <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java   |  7 +++----
 .../test/java/org/apache/hive/beeline/KyuubiBeeLineTest.java   | 10 ++++++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git 
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java 
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java
index bcfa6944e..9498c1156 100644
--- 
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java
+++ 
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/KyuubiBeeLine.java
@@ -218,7 +218,7 @@ public class KyuubiBeeLine extends BeeLine {
     if (!commands.isEmpty()) {
       for (String command : commands) {
         debug(loc("executing-command", command));
-        if (!dispatch(command)) {
+        if (!removeCommentsDispatch(command)) {
           code++;
         }
       }
@@ -282,9 +282,8 @@ public class KyuubiBeeLine extends BeeLine {
     return executionResult;
   }
 
-  // see HIVE-15820: comment at the head of beeline -e
-  @Override
-  boolean dispatch(String line) {
+  // see HIVE-15820: comment at the head of beeline -e only dispatch commands
+  boolean removeCommentsDispatch(String line) {
     return super.dispatch(isPythonMode() ? line : 
HiveStringUtils.removeComments(line));
   }
 
diff --git 
a/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/KyuubiBeeLineTest.java
 
b/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/KyuubiBeeLineTest.java
index 8b87b13a0..a58d9057c 100644
--- 
a/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/KyuubiBeeLineTest.java
+++ 
b/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/KyuubiBeeLineTest.java
@@ -95,12 +95,14 @@ public class KyuubiBeeLineTest {
 
   @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);
@@ -122,12 +124,14 @@ public class KyuubiBeeLineTest {
     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(
@@ -135,6 +139,12 @@ public class KyuubiBeeLineTest {
           "-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 {

Reply via email to