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 28a1c735a [KYUUBI #6506] `kyuubi-beeline` supports `--conf`
28a1c735a is described below

commit 28a1c735af042d984f91571b73c5d23e15248c21
Author: Bruce Wong <[email protected]>
AuthorDate: Thu Jun 27 22:12:25 2024 +0800

    [KYUUBI #6506] `kyuubi-beeline` supports `--conf`
    
    # :mag: Description
    ## Issue References ๐Ÿ”—
    
    This pull request fixes #6506
    
    ## Describe Your Solution ๐Ÿ”ง
    
    Set the alias `--conf` to `--hiveconf`.
    
    ## Types of changes :bookmark:
    
    - [ ] Bugfix (non-breaking change which fixes an issue)
    - [x] 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:
    ```
    # use --hiveconf or --hivevar to set some configurations
    kyuubi-beeline -u 'jdbc:kyuubi://kyuubi:10009/' \
        --hiveconf kyuubi.operation.result.format=arrow \
        --hiveconf kyuubi.operation.incremental.collect=true-f \
        --hivevar app_name=xxx \
        xxx.sql
    ```
    
    #### Behavior With This Pull Request :tada:
    ```
    # use --conf to set some configurations
    kyuubi-beeline -u 'jdbc:kyuubi://kyuubi:10009/' \
        --conf kyuubi.operation.result.format=arrow \
        --conf kyuubi.operation.incremental.collect=true-f \
        --conf app_name=xxx \
        xxx.sql
    ```
    
    #### Related Unit Tests
    
    ---
    
    # Checklist ๐Ÿ“
    
    - [x] This patch was not authored or co-authored using [Generative 
Tooling](https://www.apache.org/legal/generative-tooling.html)
    
    **Be nice. Be informative.**
    
    Closes #6511 from BruceWong96/support-beeline-conf.
    
    Closes #6506
    
    7a81455d8 [Bruce Wong] fix code style.
    8d1fec242 [Bruce Wong] delete some spaces.
    d64505dd7 [Bruce Wong] [FEATURE] kyuubi-beeline supports --conf.
    
    Authored-by: Bruce Wong <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 docs/client/cli/kyuubi_beeline.md                      |  1 +
 .../src/main/java/org/apache/hive/beeline/BeeLine.java | 18 +++++++++++++++++-
 .../src/main/resources/BeeLine.properties              |  1 +
 .../org/apache/hive/beeline/TestBeelineArgParsing.java | 10 ++++++++--
 4 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/docs/client/cli/kyuubi_beeline.md 
b/docs/client/cli/kyuubi_beeline.md
index fc6916c3e..5e8fe13b0 100644
--- a/docs/client/cli/kyuubi_beeline.md
+++ b/docs/client/cli/kyuubi_beeline.md
@@ -49,6 +49,7 @@ Options:
   -f <exec file>                  Script file that should be executed.
   -w, --password-file <file>      The password file to read password from.
   --hiveconf property=value       Use value for given property.
+  --conf property=value           Alias of --hiveconf.
   --hivevar name=value            Hive variable name and value.
                                   This is Hive specific settings in which 
variables
                                   can be set at session level and referenced 
in Hive
diff --git 
a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/BeeLine.java 
b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/BeeLine.java
index 3f749334e..db06cf08f 100644
--- a/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/BeeLine.java
+++ b/kyuubi-hive-beeline/src/main/java/org/apache/hive/beeline/BeeLine.java
@@ -159,6 +159,7 @@ public class BeeLine implements Closeable {
 
   private static final String HIVE_VAR_PREFIX = "--hivevar";
   private static final String HIVE_CONF_PREFIX = "--hiveconf";
+  private static final String CONF_PREFIX = "--conf";
   private static final String PROP_FILE_PREFIX = "--property-file";
   static final String PASSWD_MASK = "[passwd stripped]";
 
@@ -377,6 +378,15 @@ public class BeeLine implements Closeable {
             .withDescription("Use value for given property")
             .create());
 
+    // conf option --conf
+    options.addOption(
+        OptionBuilder.withValueSeparator()
+            .hasArgs(2)
+            .withArgName("property=value")
+            .withLongOpt("conf")
+            .withDescription("Alias of --hiveconf")
+            .create());
+
     // --property-file <file>
     options.addOption(
         OptionBuilder.hasArg()
@@ -671,7 +681,8 @@ public class BeeLine implements Closeable {
     private boolean isBeeLineOpt(String arg) {
       return arg.startsWith("--")
           && !(HIVE_VAR_PREFIX.equals(arg)
-              || (HIVE_CONF_PREFIX.equals(arg))
+              || HIVE_CONF_PREFIX.equals(arg)
+              || CONF_PREFIX.equals(arg)
               || "--help".equals(arg)
               || PROP_FILE_PREFIX.equals(arg));
     }
@@ -751,6 +762,11 @@ public class BeeLine implements Closeable {
       setHiveConfVar(key, hiveConfs.getProperty(key));
     }
 
+    Properties confs = cl.getOptionProperties("conf");
+    for (String key : confs.stringPropertyNames()) {
+      setHiveConfVar(key, confs.getProperty(key));
+    }
+
     driver = cl.getOptionValue("d");
     auth = cl.getOptionValue("a");
     user = cl.getOptionValue("n");
diff --git a/kyuubi-hive-beeline/src/main/resources/BeeLine.properties 
b/kyuubi-hive-beeline/src/main/resources/BeeLine.properties
index 3ae9e26d7..0bb3d974e 100644
--- a/kyuubi-hive-beeline/src/main/resources/BeeLine.properties
+++ b/kyuubi-hive-beeline/src/main/resources/BeeLine.properties
@@ -169,6 +169,7 @@ Options:\n\
 \  -f <exec file>                  Script file that should be executed.\n\
 \  -w, --password-file <file>      The password file to read password from.\n\
 \  --hiveconf property=value       Use value for given property.\n\
+\  --conf property=value           Alias of --hiveconf. \n\
 \  --hivevar name=value            Hive variable name and value.\n\
 \                                  This is Hive specific settings in which 
variables\n\
 \                                  can be set at session level and referenced 
in Hive\n\
diff --git 
a/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/TestBeelineArgParsing.java
 
b/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/TestBeelineArgParsing.java
index e6f92be73..dc4a318f1 100644
--- 
a/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/TestBeelineArgParsing.java
+++ 
b/kyuubi-hive-beeline/src/test/java/org/apache/hive/beeline/TestBeelineArgParsing.java
@@ -210,7 +210,7 @@ public class TestBeelineArgParsing {
     Assert.assertTrue(bl.queries.contains("select2"));
   }
 
-  /** Test setting hive conf and hive vars with --hiveconf and --hivevar */
+  /** Test setting hive conf and hive vars with --hiveconf, --hivevar and 
--conf */
   @Test
   public void testHiveConfAndVars() throws Exception {
     TestBeeline bl = new TestBeeline();
@@ -231,7 +231,11 @@ public class TestBeelineArgParsing {
           "--hivevar",
           "c=cvalue",
           "--hivevar",
-          "d=dvalue"
+          "d=dvalue",
+          "--conf",
+          "e=evalue",
+          "--conf",
+          "f=fvalue"
         };
     Assert.assertEquals(0, bl.initArgs(args));
     Assert.assertTrue(bl.connectArgs.equals("url name password driver"));
@@ -239,6 +243,8 @@ public class TestBeelineArgParsing {
     
Assert.assertTrue(bl.getOpts().getHiveConfVariables().get("b").equals("bvalue"));
     
Assert.assertTrue(bl.getOpts().getHiveVariables().get("c").equals("cvalue"));
     
Assert.assertTrue(bl.getOpts().getHiveVariables().get("d").equals("dvalue"));
+    
Assert.assertTrue(bl.getOpts().getHiveConfVariables().get("e").equals("evalue"));
+    
Assert.assertTrue(bl.getOpts().getHiveConfVariables().get("f").equals("fvalue"));
   }
 
   @Test

Reply via email to