diff --git ql/src/java/org/apache/hadoop/hive/ql/hooks/Entity.java ql/src/java/org/apache/hadoop/hive/ql/hooks/Entity.java index d1e25d7..47aed70 100644 --- ql/src/java/org/apache/hadoop/hive/ql/hooks/Entity.java +++ ql/src/java/org/apache/hadoop/hive/ql/hooks/Entity.java @@ -22,11 +22,10 @@ import java.net.URI; import java.util.Map; -import org.apache.hadoop.hive.ql.metadata.Partition; +import org.apache.hadoop.hive.ql.exec.FunctionInfo; import org.apache.hadoop.hive.ql.metadata.DummyPartition; +import org.apache.hadoop.hive.ql.metadata.Partition; import org.apache.hadoop.hive.ql.metadata.Table; -import org.apache.hadoop.hive.ql.session.SessionState; -import org.apache.hadoop.hive.conf.HiveConf; /** * This class encapsulates an object that is being read or written to by the @@ -40,7 +39,7 @@ * The type of the entity. */ public static enum Type { - TABLE, PARTITION, DUMMYPARTITION, DFS_DIR, LOCAL_DIR + TABLE, PARTITION, DUMMYPARTITION, DFS_DIR, LOCAL_DIR, UDF }; /** @@ -64,6 +63,10 @@ private String d; /** + * If this is a function + */ + private FunctionInfo udf; + /** * This is derived from t and p, but we need to serialize this field to make * sure Entity.hashCode() does not need to recursively read into t and p. */ @@ -201,6 +204,13 @@ public Entity(String d, boolean islocal, boolean complete) { this.complete = complete; } + public Entity (FunctionInfo udf) { + this.udf = udf; + typ = Type.UDF; + name = computeName(); + complete = true; + } + /** * Get the parameter map of the Entity. */ @@ -253,6 +263,13 @@ public Table getTable() { } /** + * Get the UDF associated with the entity. + */ + public FunctionInfo getUDF() { + return udf; + } + + /** * toString function. */ @Override @@ -268,6 +285,8 @@ private String computeName() { return t.getDbName() + "@" + t.getTableName() + "@" + p.getName(); case DUMMYPARTITION: return p.getName(); + case UDF: + return udf.getDisplayName(); default: return d; } diff --git ql/src/java/org/apache/hadoop/hive/ql/hooks/ReadEntity.java ql/src/java/org/apache/hadoop/hive/ql/hooks/ReadEntity.java index 555faca..d4cb310 100644 --- ql/src/java/org/apache/hadoop/hive/ql/hooks/ReadEntity.java +++ ql/src/java/org/apache/hadoop/hive/ql/hooks/ReadEntity.java @@ -22,6 +22,7 @@ import java.util.HashSet; import java.util.Set; +import org.apache.hadoop.hive.ql.exec.FunctionInfo; import org.apache.hadoop.hive.ql.metadata.Partition; import org.apache.hadoop.hive.ql.metadata.Table; @@ -85,6 +86,10 @@ public ReadEntity(Partition p, ReadEntity parent) { return parents; } + public ReadEntity (FunctionInfo udf) { + super(udf); + } + /** * Equals function. */ diff --git ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java index 79457b4..ce36944 100644 --- ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java +++ ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java @@ -417,6 +417,9 @@ private void doPhase1GetAllAggregations(ASTNode expressionTree, if (expressionTree.getChild(0).getType() == HiveParser.Identifier) { String functionName = unescapeIdentifier(expressionTree.getChild(0) .getText()); + if (conf.getBoolVar(ConfVars.HIVE_EXTENDED_ENITITY_CAPTURE)) { + getInputs().add(new ReadEntity(FunctionRegistry.getFunctionInfo(functionName))); + } if (FunctionRegistry.getGenericUDAFResolver(functionName) != null) { aggregations.put(expressionTree.toStringTree(), expressionTree); FunctionInfo fi = FunctionRegistry.getFunctionInfo(functionName); @@ -2471,6 +2474,9 @@ private static boolean isRegex(String pattern) { FunctionInfo fi = FunctionRegistry.getFunctionInfo(funcName); if (fi != null) { genericUDTF = fi.getGenericUDTF(); + if (conf.getBoolVar(ConfVars.HIVE_EXTENDED_ENITITY_CAPTURE)) { + getInputs().add(new ReadEntity(fi)); + } } isUDTF = (genericUDTF != null); if (isUDTF) {