You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2015/01/29 18:24:10 UTC
svn commit: r1655757 -
/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFType.java
Author: thejas
Date: Thu Jan 29 17:24:10 2015
New Revision: 1655757
URL: http://svn.apache.org/r1655757
Log:
HIVE-9489 : add javadoc for UDFType annotation (Thejas Nair, reviewed by Lefty Leverenz, Ashutosh Chauhan)
Modified:
hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFType.java
Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFType.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFType.java?rev=1655757&r1=1655756&r2=1655757&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFType.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/udf/UDFType.java Thu Jan 29 17:24:10 2015
@@ -23,16 +23,51 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.apache.hadoop.hive.common.classification.InterfaceAudience.Public;
+import org.apache.hadoop.hive.common.classification.InterfaceStability.Evolving;
+
/**
- * UDFType.
+ * UDFType annotations are used to describe properties of a UDF. This gives
+ * important information to the optimizer.
+ * If the UDF is not deterministic, or if it is stateful, it is necessary to
+ * annotate it as such for correctness.
*
*/
+@Public
+@Evolving
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface UDFType {
+ /**
+ * Certain optimizations should not be applied if UDF is not deterministic.
+ * Deterministic UDF returns same result each time it is invoked with a
+ * particular input. This determinism just needs to hold within the context of
+ * a query.
+ *
+ * @return true if the UDF is deterministic
+ */
boolean deterministic() default true;
+
+ /**
+ * If a UDF stores state based on the sequence of records it has processed, it
+ * is stateful. A stateful UDF cannot be used in certain expressions such as
+ * case statement and certain optimizations such as AND/OR short circuiting
+ * don't apply for such UDFs, as they need to be invoked for each record.
+ * row_sequence is an example of stateful UDF. A stateful UDF is considered to
+ * be non-deterministic, irrespective of what deterministic() returns.
+ *
+ * @return true
+ */
boolean stateful() default false;
+
+ /**
+ * A UDF is considered distinctLike if the UDF can be evaluated on just the
+ * distinct values of a column. Examples include min and max UDFs. This
+ * information is used by metadata-only optimizer.
+ *
+ * @return true if UDF is distinctLike
+ */
boolean distinctLike() default false;
/**