diff --git a/docs/client/cli/kyuubi_beeline.md b/docs/client/cli/kyuubi_beeline.md index fc6916c3e35..5e8fe13b07c 100644 --- a/docs/client/cli/kyuubi_beeline.md +++ b/docs/client/cli/kyuubi_beeline.md @@ -49,6 +49,7 @@ Options: -f Script file that should be executed. -w, --password-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 3f749334ec1..db06cf08f7e 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 options.addOption( OptionBuilder.hasArg() @@ -671,7 +681,8 @@ private void processBeeLineOpt(final String arg) { 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 @@ private boolean connectUsingArgs(BeelineParser beelineParser, CommandLine cl) { 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 3ae9e26d791..0bb3d974ed7 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 Script file that should be executed.\n\ \ -w, --password-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 e6f92be73af..dc4a318f1ab 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 void testQueryScripts() throws Exception { 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 void testHiveConfAndVars() throws Exception { "--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 void testHiveConfAndVars() throws Exception { 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