FAQ
Author: brock
Date: Sat Oct 12 15:51:20 2013
New Revision: 1531549

URL: http://svn.apache.org/r1531549
Log:
HIVE-5252 - Add ql syntax for inline java code creation (Edward Capriolo via Brock Noland)

Added:
     hive/trunk/ql/src/test/queries/clientnegative/compile_processor.q
     hive/trunk/ql/src/test/queries/clientpositive/compile_processor.q
     hive/trunk/ql/src/test/results/clientnegative/compile_processor.q.out
     hive/trunk/ql/src/test/results/clientpositive/compile_processor.q.out
Modified:
     hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
     hive/trunk/ivy/libraries.properties
     hive/trunk/ql/ivy.xml
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/CommandProcessorFactory.java
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/CompileProcessor.java
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/HiveCommand.java

Modified: hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1531549&r1=1531548&r2=1531549&view=diff
==============================================================================
--- hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Sat Oct 12 15:51:20 2013
@@ -774,7 +774,7 @@ public class HiveConf extends Configurat
      HIVE_SERVER2_TABLE_TYPE_MAPPING("hive.server2.table.type.mapping", "CLASSIC"),
      HIVE_SERVER2_SESSION_HOOK("hive.server2.session.hook", ""),

- HIVE_SECURITY_COMMAND_WHITELIST("hive.security.command.whitelist", "set,reset,dfs,add,delete"),
+ HIVE_SECURITY_COMMAND_WHITELIST("hive.security.command.whitelist", "set,reset,dfs,add,delete,compile"),

      HIVE_CONF_RESTRICTED_LIST("hive.conf.restricted.list", ""),


Modified: hive/trunk/ivy/libraries.properties
URL: http://svn.apache.org/viewvc/hive/trunk/ivy/libraries.properties?rev=1531549&r1=1531548&r2=1531549&view=diff
==============================================================================
--- hive/trunk/ivy/libraries.properties (original)
+++ hive/trunk/ivy/libraries.properties Sat Oct 12 15:51:20 2013
@@ -17,7 +17,7 @@
  # project configuration files.

  # These are the versions of our dependencies (in alphabetical order)
-apacheant.version=1.7.1
+apacheant.version=1.8.4
  ant-contrib.version=1.0b3
  ant-task.version=2.0.10
  antlr.version=3.4

Modified: hive/trunk/ql/ivy.xml
URL: http://svn.apache.org/viewvc/hive/trunk/ql/ivy.xml?rev=1531549&r1=1531548&r2=1531549&view=diff
==============================================================================
--- hive/trunk/ql/ivy.xml (original)
+++ hive/trunk/ql/ivy.xml Sat Oct 12 15:51:20 2013
@@ -51,6 +51,7 @@

      <dependency org="org.codehaus.groovy" name="groovy-all"
                  rev="${groovy.version}" />
+ <dependency org="org.apache.ant" name="ant" rev="${apacheant.version}" />

      <dependency org="org.json" name="json" rev="${json.version}"/>
      <dependency org="commons-collections" name="commons-collections" rev="${commons-collections.version}"/>

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/CommandProcessorFactory.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/CommandProcessorFactory.java?rev=1531549&r1=1531548&r2=1531549&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/CommandProcessorFactory.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/CommandProcessorFactory.java Sat Oct 12 15:51:20 2013
@@ -19,16 +19,17 @@
  package org.apache.hadoop.hive.ql.processors;

  import static org.apache.commons.lang.StringUtils.isBlank;
+
+import java.sql.SQLException;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Map;
  import java.util.Set;
-import java.sql.SQLException;

+import org.apache.hadoop.hive.conf.HiveConf;
  import org.apache.hadoop.hive.ql.Driver;
  import org.apache.hadoop.hive.ql.session.SessionState;
-import org.apache.hadoop.hive.conf.HiveConf;

  /**
   * CommandProcessorFactory.
@@ -75,6 +76,8 @@ public final class CommandProcessorFacto
          return new AddResourceProcessor();
        case DELETE:
          return new DeleteResourceProcessor();
+ case COMPILE:
+ return new CompileProcessor();
        default:
          throw new AssertionError("Unknown HiveCommand " + hiveCommand);
      }

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/CompileProcessor.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/CompileProcessor.java?rev=1531549&r1=1531548&r2=1531549&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/CompileProcessor.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/CompileProcessor.java Sat Oct 12 15:51:20 2013
@@ -19,6 +19,7 @@ import org.apache.hadoop.hive.ql.parse.V
  import org.apache.hadoop.hive.ql.session.SessionState;
  import org.apache.hadoop.hive.ql.session.SessionState.LogHelper;
  import org.apache.hadoop.hive.ql.session.SessionState.ResourceType;
+import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.types.Path;
  import org.codehaus.groovy.ant.Groovyc;
@@ -202,8 +203,11 @@ public class CompileProcessor implements
        throw new CompileProcessorException("writing file", e1);
      }
      destination.mkdir();
- g.execute();
-
+ try {
+ g.execute();
+ } catch (BuildException ex){
+ throw new CompileProcessorException("Problem compiling", ex);
+ }
      File testArchive = new File(ioTempFile, jarId + ".jar");
      JarArchiveOutputStream out = null;
      try {

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/HiveCommand.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/HiveCommand.java?rev=1531549&r1=1531548&r2=1531549&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/HiveCommand.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/processors/HiveCommand.java Sat Oct 12 15:51:20 2013
@@ -30,7 +30,8 @@ public enum HiveCommand {
    RESET(),
    DFS(),
    ADD(),
- DELETE();
+ DELETE(),
+ COMPILE();
    private static final Set<String> COMMANDS = new HashSet<String>();
    static {
      for (HiveCommand command : HiveCommand.values()) {

Added: hive/trunk/ql/src/test/queries/clientnegative/compile_processor.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientnegative/compile_processor.q?rev=1531549&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientnegative/compile_processor.q (added)
+++ hive/trunk/ql/src/test/queries/clientnegative/compile_processor.q Sat Oct 12 15:51:20 2013
@@ -0,0 +1,8 @@
+
+compile `import org.apache.hadoop.hive.ql.exec.UDF \;
+public class Pyth extsfgsfgfsends UDF {
+ public double evaluate(double a, double b){
+ return Math.sqrt((a*a) + (b*b)) \;
+ }
+} ` AS GROOVY NAMED Pyth.groovy;
+

Added: hive/trunk/ql/src/test/queries/clientpositive/compile_processor.q
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/queries/clientpositive/compile_processor.q?rev=1531549&view=auto
==============================================================================
--- hive/trunk/ql/src/test/queries/clientpositive/compile_processor.q (added)
+++ hive/trunk/ql/src/test/queries/clientpositive/compile_processor.q Sat Oct 12 15:51:20 2013
@@ -0,0 +1,11 @@
+
+compile `import org.apache.hadoop.hive.ql.exec.UDF \;
+public class Pyth extends UDF {
+ public double evaluate(double a, double b){
+ return Math.sqrt((a*a) + (b*b)) \;
+ }
+} ` AS GROOVY NAMED Pyth.groovy;
+CREATE TEMPORARY FUNCTION Pyth as 'Pyth';
+
+SELECT Pyth(3,4) FROM src limit 1;
+

Added: hive/trunk/ql/src/test/results/clientnegative/compile_processor.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientnegative/compile_processor.q.out?rev=1531549&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientnegative/compile_processor.q.out (added)
+++ hive/trunk/ql/src/test/results/clientnegative/compile_processor.q.out Sat Oct 12 15:51:20 2013
@@ -0,0 +1 @@
+Query returned non-zero code: 1, cause: Problem compiling

Added: hive/trunk/ql/src/test/results/clientpositive/compile_processor.q.out
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/test/results/clientpositive/compile_processor.q.out?rev=1531549&view=auto
==============================================================================
--- hive/trunk/ql/src/test/results/clientpositive/compile_processor.q.out (added)
+++ hive/trunk/ql/src/test/results/clientpositive/compile_processor.q.out Sat Oct 12 15:51:20 2013
@@ -0,0 +1,13 @@
+PREHOOK: query: CREATE TEMPORARY FUNCTION Pyth as 'Pyth'
+PREHOOK: type: CREATEFUNCTION
+POSTHOOK: query: CREATE TEMPORARY FUNCTION Pyth as 'Pyth'
+POSTHOOK: type: CREATEFUNCTION
+PREHOOK: query: SELECT Pyth(3,4) FROM src limit 1
+PREHOOK: type: QUERY
+PREHOOK: Input: default@src
+#### A masked pattern was here ####
+POSTHOOK: query: SELECT Pyth(3,4) FROM src limit 1
+POSTHOOK: type: QUERY
+POSTHOOK: Input: default@src
+#### A masked pattern was here ####
+5.0

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedOct 12, '13 at 3:51p
activeOct 12, '13 at 3:51p
posts1
users1
websitehive.apache.org

1 user in discussion

Brock: 1 post

People

Translate

site design / logo © 2021 Grokbase