incubator-hcatalog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1244228 - in /incubator/hcatalog/trunk: CHANGES.txt ivy/libraries.properties src/docs/src/documentation/content/xdocs/cli.xml src/java/org/apache/hcatalog/cli/HCatCli.java
Date Tue, 14 Feb 2012 21:54:44 GMT
Author: gates
Date: Tue Feb 14 21:54:43 2012
New Revision: 1244228

URL: http://svn.apache.org/viewvc?rev=1244228&view=rev
Log:
HCATALOG-255 Define hadoop properties on the hcat command line

Modified:
    incubator/hcatalog/trunk/CHANGES.txt
    incubator/hcatalog/trunk/ivy/libraries.properties
    incubator/hcatalog/trunk/src/docs/src/documentation/content/xdocs/cli.xml
    incubator/hcatalog/trunk/src/java/org/apache/hcatalog/cli/HCatCli.java

Modified: incubator/hcatalog/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/CHANGES.txt?rev=1244228&r1=1244227&r2=1244228&view=diff
==============================================================================
--- incubator/hcatalog/trunk/CHANGES.txt (original)
+++ incubator/hcatalog/trunk/CHANGES.txt Tue Feb 14 21:54:43 2012
@@ -23,6 +23,8 @@ Trunk (unreleased changes)
   INCOMPATIBLE CHANGES
 
   NEW FEATURES
+  HCAT-255 Define hadoop properties on the hcat command line (ctdean via gates)
+
   HCAT-2 Support nested schema conversion between Hive an Pig (julienledem via hashutosh)
 
   IMPROVEMENTS

Modified: incubator/hcatalog/trunk/ivy/libraries.properties
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/ivy/libraries.properties?rev=1244228&r1=1244227&r2=1244228&view=diff
==============================================================================
--- incubator/hcatalog/trunk/ivy/libraries.properties (original)
+++ incubator/hcatalog/trunk/ivy/libraries.properties Tue Feb 14 21:54:43 2012
@@ -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

Modified: incubator/hcatalog/trunk/src/docs/src/documentation/content/xdocs/cli.xml
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/docs/src/documentation/content/xdocs/cli.xml?rev=1244228&r1=1244227&r2=1244228&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/docs/src/documentation/content/xdocs/cli.xml (original)
+++ incubator/hcatalog/trunk/src/docs/src/documentation/content/xdocs/cli.xml Tue Feb 14 21:54:43
2012
@@ -47,6 +47,7 @@
 <li><strong>-p</strong>: Usage is -p rwxr-xr-x .... This indicates to HCatalog
that table that needs to be created must have permissions as "rwxr-xr-x" </li>
 <li><strong>-f</strong>: Usage is -f myscript.hcatalog .... This indicates
to hcatalog that myscript.hcatalog is a file which contains DDL commands it needs to execute.
</li>
 <li><strong>-e</strong>: Usage is -e 'create table mytable(a int);' ....
This indicates to HCatalog to treat the following string as DDL command and execute it. </li>
+<li><strong>-D</strong>: Usage is -Dname=value .... This sets the hadoop
value for given property</li>
 </ul>
 <p></p>	
 <p>Note the following:</p>
@@ -59,7 +60,7 @@
 </li>
 <li>If no option is provided, then a usage message is printed: 
 <source>
-Usage: hcat  { -e "&lt;query&gt;" | -f "&lt;filepath&gt;" } [-g "&lt;group&gt;"
] [-p "&lt;perms&gt;"]
+Usage: hcat  { -e "&lt;query&gt;" | -f "&lt;filepath&gt;" } [-g "&lt;group&gt;"
] [-p "&lt;perms&gt;"] [-D "&lt;name&gt;=&lt;value&gt;"]
 </source>
 </li>
 </ul>

Modified: incubator/hcatalog/trunk/src/java/org/apache/hcatalog/cli/HCatCli.java
URL: http://svn.apache.org/viewvc/incubator/hcatalog/trunk/src/java/org/apache/hcatalog/cli/HCatCli.java?rev=1244228&r1=1244227&r2=1244228&view=diff
==============================================================================
--- incubator/hcatalog/trunk/src/java/org/apache/hcatalog/cli/HCatCli.java (original)
+++ incubator/hcatalog/trunk/src/java/org/apache/hcatalog/cli/HCatCli.java Tue Feb 14 21:54:43
2012
@@ -26,6 +26,7 @@ import java.io.PrintStream;
 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 @@ public class HCatCli {
         .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 @@ public class HCatCli {
       conf.set(HCatConstants.HCAT_GROUP, grp);
     }
 
+    // -D
+    setConfProperties(conf, cmdLine.getOptionProperties("D"));
+
     if (execString != null) {
       System.exit(processLine(execString));
     }
@@ -167,6 +179,11 @@ public class HCatCli {
     System.exit(1);
   }
 
+  private static void setConfProperties(HiveConf conf, Properties props) {
+    for(java.util.Map.Entry<Object, Object> e : props.entrySet())
+        conf.set((String) e.getKey(), (String) e.getValue());
+  }
+
   private static int processLine(String line) {
     int ret = 0;
 
@@ -268,7 +285,7 @@ public class HCatCli {
   private static void printUsage(Options options, OutputStream os) {
     PrintWriter pw = new PrintWriter(os);
     new HelpFormatter().printHelp(pw, 2 * HelpFormatter.DEFAULT_WIDTH,
-        "hcat { -e \"<query>\" | -f \"<filepath>\" } [ -g \"<group>\" ]
[ -p \"<perms>\" ]",
+      "hcat { -e \"<query>\" | -f \"<filepath>\" } [ -g \"<group>\" ] [
-p \"<perms>\" ] [ -D\"<name>=<value>\" ]",
         null,options, HelpFormatter.DEFAULT_LEFT_PAD,HelpFormatter.DEFAULT_DESC_PAD,
         null, false);
     pw.flush();



Mime
View raw message