Index: src/java/org/apache/hcatalog/cli/HCatCli.java =================================================================== --- src/java/org/apache/hcatalog/cli/HCatCli.java (revision 1240900) +++ src/java/org/apache/hcatalog/cli/HCatCli.java (working copy) @@ -26,6 +26,7 @@ import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.util.ArrayList; +import java.util.Properties; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.GnuParser; @@ -105,6 +106,14 @@ .withDescription("permissions for the db/table specified in CREATE statement") .create('p')); + // -D + options.addOption(OptionBuilder + .hasArgs(2) + .withArgName("property=value") + .withValueSeparator() + .withDescription("use hadoop value for given property") + .create('D')); + // [-h|--help] options.addOption(new Option("h", "help", false, "Print help information")); @@ -146,6 +155,9 @@ conf.set(HCatConstants.HCAT_GROUP, grp); } + // -D + setConfProperties(conf, cmdLine.getOptionProperties("D")); + if (execString != null) { System.exit(processLine(execString)); } @@ -167,6 +179,11 @@ System.exit(1); } + private static void setConfProperties(HiveConf conf, Properties props) { + for(java.util.Map.Entry e : props.entrySet()) + conf.set((String) e.getKey(), (String) e.getValue()); + } + private static int processLine(String line) { int ret = 0; @@ -268,7 +285,7 @@ private static void printUsage(Options options, OutputStream os) { PrintWriter pw = new PrintWriter(os); new HelpFormatter().printHelp(pw, 2 * HelpFormatter.DEFAULT_WIDTH, - "hcat { -e \"\" | -f \"\" } [ -g \"\" ] [ -p \"\" ]", + "hcat { -e \"\" | -f \"\" } [ -g \"\" ] [ -p \"\" ] [ -D\"=\" ]", null,options, HelpFormatter.DEFAULT_LEFT_PAD,HelpFormatter.DEFAULT_DESC_PAD, null, false); pw.flush(); Index: src/docs/src/documentation/content/xdocs/cli.xml =================================================================== --- src/docs/src/documentation/content/xdocs/cli.xml (revision 1240900) +++ src/docs/src/documentation/content/xdocs/cli.xml (working copy) @@ -47,6 +47,7 @@
  • -p: Usage is -p rwxr-xr-x .... This indicates to HCatalog that table that needs to be created must have permissions as "rwxr-xr-x"
  • -f: Usage is -f myscript.hcatalog .... This indicates to hcatalog that myscript.hcatalog is a file which contains DDL commands it needs to execute.
  • -e: Usage is -e 'create table mytable(a int);' .... This indicates to HCatalog to treat the following string as DDL command and execute it.
  • +
  • -D: Usage is -Dname=value .... This sets the hadoop value for given property
  • Note the following:

    @@ -59,7 +60,7 @@
  • If no option is provided, then a usage message is printed: -Usage: hcat { -e "<query>" | -f "<filepath>" } [-g "<group>" ] [-p "<perms>"] +Usage: hcat { -e "<query>" | -f "<filepath>" } [-g "<group>" ] [-p "<perms>"] [-D "<name>=<value>"]
  • Index: ivy/libraries.properties =================================================================== --- ivy/libraries.properties (revision 1240900) +++ ivy/libraries.properties (working copy) @@ -16,7 +16,7 @@ junit.version=3.8.1 ivy.version=2.1.0 pig.version=0.8.0 -commons-cli.version=1.0 +commons-cli.version=1.2 #hadoop-core.version=0.20.2 Waiting for a secure version of hadoop in maven hadoop-tools.version=0.20.205.0 jms.version=1.1