FAQ
Author: gunther
Date: Tue Sep 9 03:31:52 2014
New Revision: 1623617

URL: http://svn.apache.org/r1623617
Log:
HIVE-8027: CBO: Bail out for LV, Unique Joins, PTF, TF…, Add annotations to UDFs (Laljo John Pullokkaran via Gunther Hagleitner)

Modified:
     hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleAvg.java
     hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleGroupConcat.java
     hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleMaxN.java
     hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleMinN.java
     hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleAdd.java
     hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleArraySum.java
     hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleFormat.java
     hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleMapConcat.java
     hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleStructPrint.java
     hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udtf/example/GenericUDTFCount2.java
     hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDAFTestMax.java
     hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFFileLookup.java
     hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestErrorOnFalse.java
     hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestLength.java
     hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestLength2.java
     hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/DummyContextUDF.java
     hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestGetJavaBoolean.java
     hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestGetJavaString.java
     hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestTranslate.java
     hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/QueryProperties.java
     hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/stats/FilterSelectivityEstimator.java
     hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/SqlFunctionConverter.java
     hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
     hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_correctness.q
     hive/branches/cbo/ql/src/test/results/clientpositive/cbo_correctness.q.out

Modified: hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleAvg.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleAvg.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleAvg.java (original)
+++ hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleAvg.java Tue Sep 9 03:31:52 2014
@@ -18,6 +18,7 @@

  package org.apache.hadoop.hive.contrib.udaf.example;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDAF;
  import org.apache.hadoop.hive.ql.exec.UDAFEvaluator;

@@ -32,6 +33,8 @@ import org.apache.hadoop.hive.ql.exec.UD
   * more efficient.
   *
   */
+@Description(name = "example_avg",
+value = "_FUNC_(col) - Example UDAF to compute average")
  public final class UDAFExampleAvg extends UDAF {

    /**

Modified: hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleGroupConcat.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleGroupConcat.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleGroupConcat.java (original)
+++ hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleGroupConcat.java Tue Sep 9 03:31:52 2014
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.contrib.u
  import java.util.ArrayList;
  import java.util.Collections;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDAF;
  import org.apache.hadoop.hive.ql.exec.UDAFEvaluator;

@@ -35,6 +36,8 @@ import org.apache.hadoop.hive.ql.exec.UD
   * implement built-in aggregation functions, which are harder to program but
   * more efficient.
   */
+@Description(name = "example_group_concat",
+value = "_FUNC_(col) - Example UDAF that concatenates all arguments from different rows into a single string")
  public class UDAFExampleGroupConcat extends UDAF {

    /**

Modified: hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleMaxN.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleMaxN.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleMaxN.java (original)
+++ hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleMaxN.java Tue Sep 9 03:31:52 2014
@@ -19,11 +19,13 @@

  package org.apache.hadoop.hive.contrib.udaf.example;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDAF;

  /**
   * Returns the max N double values.
   */
+@Description(name = "example_max_n", value = "_FUNC_(expr) - Example UDAF that returns the max N double values")
  public class UDAFExampleMaxN extends UDAF {

    /**

Modified: hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleMinN.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleMinN.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleMinN.java (original)
+++ hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udaf/example/UDAFExampleMinN.java Tue Sep 9 03:31:52 2014
@@ -19,11 +19,13 @@

  package org.apache.hadoop.hive.contrib.udaf.example;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDAF;

  /**
   * Returns the min N double values.
   */
+@Description(name = "example_min_n", value = "_FUNC_(expr) - Example UDAF that returns the min N double values")
  public class UDAFExampleMinN extends UDAF{

    /**

Modified: hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleAdd.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleAdd.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleAdd.java (original)
+++ hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleAdd.java Tue Sep 9 03:31:52 2014
@@ -17,12 +17,14 @@
   */
  package org.apache.hadoop.hive.contrib.udf.example;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDF;

  /**
   * UDFExampleAdd.
   *
   */
+@Description(name = "example_add", value = "_FUNC_(expr) - Example UDAF that returns the sum")
  public class UDFExampleAdd extends UDF {

    public Integer evaluate(Integer... a) {

Modified: hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleArraySum.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleArraySum.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleArraySum.java (original)
+++ hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleArraySum.java Tue Sep 9 03:31:52 2014
@@ -19,12 +19,14 @@ package org.apache.hadoop.hive.contrib.u

  import java.util.List;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDF;

  /**
   * UDFExampleArraySum.
   *
   */
+@Description(name = "example_arraysum", value = "_FUNC_(expr) - Example UDAF that returns the sum")
  public class UDFExampleArraySum extends UDF {

    public Double evaluate(List<Double> a) {

Modified: hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleFormat.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleFormat.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleFormat.java (original)
+++ hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleFormat.java Tue Sep 9 03:31:52 2014
@@ -17,12 +17,14 @@
   */
  package org.apache.hadoop.hive.contrib.udf.example;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDF;

  /**
   * UDFExampleFormat.
   *
   */
+@Description(name = "example_format", value = "_FUNC_(expr) - Example UDAF that returns formated String")
  public class UDFExampleFormat extends UDF {

    public String evaluate(String format, Object... args) {

Modified: hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleMapConcat.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleMapConcat.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleMapConcat.java (original)
+++ hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleMapConcat.java Tue Sep 9 03:31:52 2014
@@ -21,12 +21,15 @@ import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Map;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDF;

  /**
   * UDFExampleMapConcat.
   *
   */
+@Description(name = "example_mapconcat",
+value = "_FUNC_(expr) - Example UDAF that returns contents of Map as a formated String")
  public class UDFExampleMapConcat extends UDF {

    public String evaluate(Map<String, String> a) {

Modified: hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleStructPrint.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleStructPrint.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleStructPrint.java (original)
+++ hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udf/example/UDFExampleStructPrint.java Tue Sep 9 03:31:52 2014
@@ -19,12 +19,15 @@ package org.apache.hadoop.hive.contrib.u

  import java.util.List;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDF;

  /**
   * UDFExampleStructPrint.
   *
   */
+@Description(name = "example_structprint",
+value = "_FUNC_(obj) - Example UDAF that returns contents of an object")
  public class UDFExampleStructPrint extends UDF {

    public String evaluate(Object a) {

Modified: hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udtf/example/GenericUDTFCount2.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udtf/example/GenericUDTFCount2.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udtf/example/GenericUDTFCount2.java (original)
+++ hive/branches/cbo/contrib/src/java/org/apache/hadoop/hive/contrib/udtf/example/GenericUDTFCount2.java Tue Sep 9 03:31:52 2014
@@ -20,6 +20,7 @@ package org.apache.hadoop.hive.contrib.u

  import java.util.ArrayList;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
  import org.apache.hadoop.hive.ql.metadata.HiveException;
  import org.apache.hadoop.hive.ql.udf.generic.GenericUDTF;
@@ -34,6 +35,8 @@ import org.apache.hadoop.hive.serde2.obj
   * to test outputting of rows on close with lateral view.
   *
   */
+@Description(name = "udtfCount2",
+value = "_FUNC_(col) - UDF outputs the number of rows seen, twice.")
  public class GenericUDTFCount2 extends GenericUDTF {

    private transient Integer count = Integer.valueOf(0);

Modified: hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDAFTestMax.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDAFTestMax.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDAFTestMax.java (original)
+++ hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDAFTestMax.java Tue Sep 9 03:31:52 2014
@@ -18,6 +18,7 @@

  package org.apache.hadoop.hive.ql.udf;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDAF;
  import org.apache.hadoop.hive.ql.exec.UDAFEvaluator;
  import org.apache.hadoop.hive.serde2.io.DoubleWritable;
@@ -32,6 +33,8 @@ import org.apache.hadoop.io.Text;
   * UDAFTestMax.
   *
   */
+@Description(name = "test_max",
+value = "_FUNC_(col) - UDF to report Max Value")
  public class UDAFTestMax extends UDAF {

    /**

Modified: hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFFileLookup.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFFileLookup.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFFileLookup.java (original)
+++ hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFFileLookup.java Tue Sep 9 03:31:52 2014
@@ -27,6 +27,7 @@ import java.util.Map;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDF;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.Text;
@@ -34,6 +35,8 @@ import org.apache.hadoop.io.Text;
  /**
   * A UDF for testing, which does key/value lookup from a file
   */
+@Description(name = "lookup",
+value = "_FUNC_(col) - UDF for key/value lookup from a file")
  public class UDFFileLookup extends UDF {
    static Log LOG = LogFactory.getLog(UDFFileLookup.class);


Modified: hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestErrorOnFalse.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestErrorOnFalse.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestErrorOnFalse.java (original)
+++ hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestErrorOnFalse.java Tue Sep 9 03:31:52 2014
@@ -18,11 +18,14 @@

  package org.apache.hadoop.hive.ql.udf;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDF;

  /**
   * A UDF for testing, which throws RuntimeException if the length of a string.
   */
+@Description(name = "test_error",
+value = "_FUNC_(col) - UDF throws RuntimeException if expression evaluates to false")
  public class UDFTestErrorOnFalse extends UDF {

    public int evaluate(Boolean b) {

Modified: hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestLength.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestLength.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestLength.java (original)
+++ hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestLength.java Tue Sep 9 03:31:52 2014
@@ -18,6 +18,7 @@

  package org.apache.hadoop.hive.ql.udf;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDF;
  import org.apache.hadoop.io.IntWritable;
  import org.apache.hadoop.io.Text;
@@ -25,6 +26,8 @@ import org.apache.hadoop.io.Text;
  /**
   * A UDF for testing, which evaluates the length of a string.
   */
+@Description(name = "testlength",
+value = "_FUNC_(col) - UDF evaluates the length of the string")
  public class UDFTestLength extends UDF {

    IntWritable result = new IntWritable();

Modified: hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestLength2.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestLength2.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestLength2.java (original)
+++ hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/UDFTestLength2.java Tue Sep 9 03:31:52 2014
@@ -18,12 +18,15 @@

  package org.apache.hadoop.hive.ql.udf;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDF;

  /**
   * A UDF for testing, which evaluates the length of a string. This UDF uses Java
   * Primitive classes for parameters.
   */
+@Description(name = "testlength2",
+value = "_FUNC_(col) - UDF evaluates the length of the string and returns value as Java Integer")
  public class UDFTestLength2 extends UDF {

    public Integer evaluate(String s) {

Modified: hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/DummyContextUDF.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/DummyContextUDF.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/DummyContextUDF.java (original)
+++ hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/DummyContextUDF.java Tue Sep 9 03:31:52 2014
@@ -18,6 +18,7 @@

  package org.apache.hadoop.hive.ql.udf.generic;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.MapredContext;
  import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
  import org.apache.hadoop.hive.ql.metadata.HiveException;
@@ -26,7 +27,8 @@ import org.apache.hadoop.hive.serde2.obj
  import org.apache.hadoop.io.LongWritable;
  import org.apache.hadoop.mapred.Counters;
  import org.apache.hadoop.mapred.Reporter;
-
+@Description(name = "counter",
+value = "_FUNC_(col) - UDF to report MR counter values")
  public class DummyContextUDF extends GenericUDF {

    private MapredContext context;

Modified: hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestGetJavaBoolean.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestGetJavaBoolean.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestGetJavaBoolean.java (original)
+++ hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestGetJavaBoolean.java Tue Sep 9 03:31:52 2014
@@ -18,6 +18,7 @@

  package org.apache.hadoop.hive.ql.udf.generic;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
  import org.apache.hadoop.hive.ql.metadata.HiveException;
  import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -27,6 +28,8 @@ import org.apache.hadoop.hive.serde2.obj
  /**
   * A test GenericUDF to return native Java's boolean type
   */
+@Description(name = "test_udf_get_java_boolean",
+value = "_FUNC_(str) - GenericUDF to return native Java's boolean type")
  public class GenericUDFTestGetJavaBoolean extends GenericUDF {
    ObjectInspector[] argumentOIs;


Modified: hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestGetJavaString.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestGetJavaString.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestGetJavaString.java (original)
+++ hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestGetJavaString.java Tue Sep 9 03:31:52 2014
@@ -18,6 +18,7 @@

  package org.apache.hadoop.hive.ql.udf.generic;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
  import org.apache.hadoop.hive.ql.metadata.HiveException;
  import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
@@ -27,6 +28,8 @@ import org.apache.hadoop.hive.serde2.obj
  /**
   * A test GenericUDF to return native Java's string type
   */
+@Description(name = "test_udf_get_java_string",
+value = "_FUNC_(str) - GenericUDF to return native Java's string type")
  public class GenericUDFTestGetJavaString extends GenericUDF {
    ObjectInspector[] argumentOIs;


Modified: hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestTranslate.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestTranslate.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestTranslate.java (original)
+++ hive/branches/cbo/itests/util/src/main/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFTestTranslate.java Tue Sep 9 03:31:52 2014
@@ -21,6 +21,7 @@ package org.apache.hadoop.hive.ql.udf.ge
  import java.util.HashSet;
  import java.util.Set;

+import org.apache.hadoop.hive.ql.exec.Description;
  import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
  import org.apache.hadoop.hive.ql.exec.UDFArgumentLengthException;
  import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
@@ -34,6 +35,8 @@ import org.apache.hadoop.io.Text;
  /**
   * Mimics oracle's function translate(str1, str2, str3).
   */
+@Description(name = "test_translate",
+value = "_FUNC_(str1, str2, str3) - Mimics oracle's function translate(str1, str2, str3)")
  public class GenericUDFTestTranslate extends GenericUDF {
    private transient ObjectInspector[] argumentOIs;


Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/QueryProperties.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/QueryProperties.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/QueryProperties.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/QueryProperties.java Tue Sep 9 03:31:52 2014
@@ -50,6 +50,7 @@ public class QueryProperties {

    private int noOfJoins = 0;
    private int noOfOuterJoins = 0;
+ private boolean hasLateralViews;

    private boolean multiDestQuery;
    private boolean filterWithSubQuery;
@@ -72,6 +73,14 @@ public class QueryProperties {
      return noOfOuterJoins;
    }

+ public void setHasLateralViews(boolean hasLateralViews) {
+ this.hasLateralViews = hasLateralViews;
+ }
+
+ public boolean hasLateralViews() {
+ return hasLateralViews;
+ }
+
    public boolean hasGroupBy() {
      return hasGroupBy;
    }

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/stats/FilterSelectivityEstimator.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/stats/FilterSelectivityEstimator.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/stats/FilterSelectivityEstimator.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/stats/FilterSelectivityEstimator.java Tue Sep 9 03:31:52 2014
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
  package org.apache.hadoop.hive.ql.optimizer.optiq.stats;

  import java.util.BitSet;

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/SqlFunctionConverter.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/SqlFunctionConverter.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/SqlFunctionConverter.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/optimizer/optiq/translator/SqlFunctionConverter.java Tue Sep 9 03:31:52 2014
@@ -183,6 +183,11 @@ public class SqlFunctionConverter {
        if (udfAnnotation != null && udfAnnotation instanceof Description) {
          Description udfDescription = (Description) udfAnnotation;
          udfName = udfDescription.name();
+ if (udfName != null) {
+ String[] aliases = udfName.split(",");
+ if (aliases.length > 0)
+ udfName = aliases[0];
+ }
        }

        if (udfName == null || udfName.isEmpty()) {

Modified: hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java (original)
+++ hive/branches/cbo/ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java Tue Sep 9 03:31:52 2014
@@ -1110,6 +1110,7 @@ public class SemanticAnalyzer extends Ba
            processSubQuery(qb, frm);
          } else if (frm.getToken().getType() == HiveParser.TOK_LATERAL_VIEW ||
              frm.getToken().getType() == HiveParser.TOK_LATERAL_VIEW_OUTER) {
+ queryProperties.setHasLateralViews(true);
            processLateralView(qb, frm);
          } else if (isJoinToken(frm)) {
            processJoin(qb, frm);
@@ -9577,7 +9578,7 @@ public class SemanticAnalyzer extends Ba
ast.getToken().getType() == HiveParser.TOK_EXPLAIN;
        if (!tokenTypeIsQuery || createVwDesc != null
!HiveConf.getBoolVar(conf, HiveConf.ConfVars.HIVE_CBO_ENABLED)
- || !canHandleQuery()) {
+ || !canHandleQuery(qb)) {
          runCBO = false;
        }

@@ -11847,17 +11848,16 @@ public class SemanticAnalyzer extends Ba
    /*
     * Entry point to Optimizations using Optiq.
     */
-
- // TODO: Extend QP to indicate LV, Multi Insert, Cubes, Rollups...
- private boolean canHandleQuery() {
+ private boolean canHandleQuery(QB qbToChk) {
      boolean runOptiqPlanner = false;
      // Assumption: If top level QB is query then everything below it must also
      // be Query
- if (qb.getIsQuery()
+ if (qbToChk.getIsQuery()
          && ((queryProperties.getJoinCount() > 1) || conf.getBoolVar(ConfVars.HIVE_IN_TEST))
          && !queryProperties.hasClusterBy() && !queryProperties.hasDistributeBy()
          && !queryProperties.hasSortBy() && !queryProperties.hasPTF()
- && !queryProperties.usesScript() && !queryProperties.hasMultiDestQuery()) {
+ && !queryProperties.usesScript() && !queryProperties.hasMultiDestQuery()
+ && !queryProperties.hasLateralViews()) {
        runOptiqPlanner = true;
      } else {
        LOG.info("Can not invoke CBO; query contains operators not supported for CBO.");
@@ -12259,7 +12259,10 @@ public class SemanticAnalyzer extends Ba
        JoinType hiveJoinType = null;

        if (joinParseTree.getToken().getType() == HiveParser.TOK_UNIQUEJOIN) {
- throw new RuntimeException("CBO does not support Unique Join");
+ String msg = String.format("UNIQUE JOIN is currently not supported in CBO,"
+ + " turn off cbo to use UNIQUE JOIN.");
+ LOG.debug(msg);
+ throw new OptiqSemanticException(msg);
        }

        // 1. Determine Join Type
@@ -13357,9 +13360,8 @@ public class SemanticAnalyzer extends Ba
              toString(
              selExprList.getChild(0).getTokenStartIndex(),
              selExprList.getChild(0).getTokenStopIndex());
- String msg = String.format("Hint specified for %s." +
- " Currently we don't support hints in CBO," +
- " turn off cbo to use hints.", hint);
+ String msg = String.format("Hint specified for %s."
+ + " Currently we don't support hints in CBO, turn off cbo to use hints.", hint);
          LOG.debug(msg);
          throw new OptiqSemanticException(msg);
        }
@@ -13370,7 +13372,10 @@ public class SemanticAnalyzer extends Ba
        // 4. Bailout if select involves Transform
        boolean isInTransform = (selExprList.getChild(posn).getChild(0).getType() == HiveParser.TOK_TRANSFORM);
        if (isInTransform) {
- throw new RuntimeException("SELECT TRANSFORM not supported");
+ String msg = String.format("SELECT TRANSFORM is currently not supported in CBO,"
+ + " turn off cbo to use TRANSFORM.");
+ LOG.debug(msg);
+ throw new OptiqSemanticException(msg);
        }

        // 5. Bailout if select involves UDTF
@@ -13384,7 +13389,10 @@ public class SemanticAnalyzer extends Ba
            genericUDTF = fi.getGenericUDTF();
          }
          if (genericUDTF != null) {
- throw new RuntimeException("SELECT UDTF not supported");
+ String msg = String.format("UDTF " + funcName + " is currently not supported in CBO,"
+ + " turn off cbo to use UDTF " + funcName);
+ LOG.debug(msg);
+ throw new OptiqSemanticException(msg);
          }
        }

@@ -13521,6 +13529,14 @@ public class SemanticAnalyzer extends Ba
        // First generate all the opInfos for the elements in the from clause
        Map<String, RelNode> aliasToRel = new HashMap<String, RelNode>();

+ // 0. Check if we can handle the query
+ // This check is needed here because of SubQuery
+ if (!canHandleQuery(qb)) {
+ String msg = String.format("CBO Can not handle Sub Query");
+ LOG.debug(msg);
+ throw new OptiqSemanticException(msg);
+ }
+
        // 1. Build Rel For Src (SubQuery, TS, Join)
        // 1.1. Recurse over the subqueries to fill the subquery part of the plan
        for (String subqAlias : qb.getSubqAliases()) {
@@ -13634,10 +13650,14 @@ public class SemanticAnalyzer extends Ba
        return hiveColNameToInputPosMapBuilder.build();
      }

- private QBParseInfo getQBParseInfo(QB qb) {
+ private QBParseInfo getQBParseInfo(QB qb) throws OptiqSemanticException {
        QBParseInfo qbp = qb.getParseInfo();
- if (qbp.getClauseNames().size() > 1)
- throw new RuntimeException("Multi Insert is not supported");
+ if (qbp.getClauseNames().size() > 1) {
+ String msg = String.format("Multi Insert is currently not supported in CBO,"
+ + " turn off cbo to use Multi Insert.");
+ LOG.debug(msg);
+ throw new OptiqSemanticException(msg);
+ }
        return qbp;
      }


Modified: hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_correctness.q
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_correctness.q?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_correctness.q (original)
+++ hive/branches/cbo/ql/src/test/queries/clientpositive/cbo_correctness.q Tue Sep 9 03:31:52 2014
@@ -332,6 +332,7 @@ having b.p_mfgr not in
    from (select p_mfgr, min(p_retailprice) l, max(p_retailprice) r, avg(p_retailprice) a from part group by p_mfgr) a
    where min(p_retailprice) = l and r - l > 600
    )
+ order by b.p_mfgr
  ;

  -- agg, non corr, having
@@ -344,6 +345,7 @@ having b.p_mfgr not in
    group by p_mfgr
    having max(p_retailprice) - min(p_retailprice) > 600
    )
+ order by b.p_mfgr
  ;

  -- 17. SubQueries In

Modified: hive/branches/cbo/ql/src/test/results/clientpositive/cbo_correctness.q.out
URL: http://svn.apache.org/viewvc/hive/branches/cbo/ql/src/test/results/clientpositive/cbo_correctness.q.out?rev=1623617&r1=1623616&r2=1623617&view=diff
==============================================================================
--- hive/branches/cbo/ql/src/test/results/clientpositive/cbo_correctness.q.out (original)
+++ hive/branches/cbo/ql/src/test/results/clientpositive/cbo_correctness.q.out Tue Sep 9 03:31:52 2014
@@ -18449,6 +18449,7 @@ having b.p_mfgr not in
    from (select p_mfgr, min(p_retailprice) l, max(p_retailprice) r, avg(p_retailprice) a from part group by p_mfgr) a
    where min(p_retailprice) = l and r - l > 600
    )
+ order by b.p_mfgr
  PREHOOK: type: QUERY
  PREHOOK: Input: default@part
  #### A masked pattern was here ####
@@ -18463,6 +18464,7 @@ having b.p_mfgr not in
    from (select p_mfgr, min(p_retailprice) l, max(p_retailprice) r, avg(p_retailprice) a from part group by p_mfgr) a
    where min(p_retailprice) = l and r - l > 600
    )
+ order by b.p_mfgr
  POSTHOOK: type: QUERY
  POSTHOOK: Input: default@part
  #### A masked pattern was here ####
@@ -18478,6 +18480,7 @@ having b.p_mfgr not in
    group by p_mfgr
    having max(p_retailprice) - min(p_retailprice) > 600
    )
+ order by b.p_mfgr
  PREHOOK: type: QUERY
  PREHOOK: Input: default@part
  #### A masked pattern was here ####
@@ -18491,11 +18494,12 @@ having b.p_mfgr not in
    group by p_mfgr
    having max(p_retailprice) - min(p_retailprice) > 600
    )
+ order by b.p_mfgr
  POSTHOOK: type: QUERY
  POSTHOOK: Input: default@part
  #### A masked pattern was here ####
-Manufacturer#2 1690.68
  Manufacturer#1 1173.15
+Manufacturer#2 1690.68
  PREHOOK: query: -- 17. SubQueries In
  -- non agg, non corr
  select *

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedSep 9, '14 at 3:32a
activeSep 9, '14 at 3:32a
posts1
users1
websitehive.apache.org

1 user in discussion

Gunther: 1 post

People

Translate

site design / logo © 2021 Grokbase