diff --git ql/src/java/org/apache/hadoop/hive/ql/ddl/function/desc/DescFunctionOperation.java ql/src/java/org/apache/hadoop/hive/ql/ddl/function/desc/DescFunctionOperation.java index 6a94a93ef9..d8a169fd0f 100644 --- ql/src/java/org/apache/hadoop/hive/ql/ddl/function/desc/DescFunctionOperation.java +++ ql/src/java/org/apache/hadoop/hive/ql/ddl/function/desc/DescFunctionOperation.java @@ -33,6 +33,7 @@ import java.util.Set; import org.apache.hadoop.hive.ql.ddl.DDLOperation; +import org.apache.hadoop.hive.ql.exec.WindowFunctionDescription; import org.apache.hadoop.hive.ql.metadata.HiveException; import org.apache.hadoop.hive.ql.parse.SemanticException; import org.apache.hive.common.util.AnnotationUtils; @@ -51,9 +52,7 @@ public int execute() throws HiveException { String funcName = desc.getName(); FunctionInfo functionInfo = FunctionRegistry.getFunctionInfo(funcName); Class funcClass = functionInfo == null ? null : functionInfo.getFunctionClass(); - Description description = funcClass == null ? null : AnnotationUtils.getAnnotation(funcClass, Description.class); - - printBaseInfo(outStream, funcName, funcClass, description); + printBaseInfo(outStream, funcName, funcClass, getDescription(funcClass)); outStream.write(Utilities.newLineCode); printExtendedInfoIfRequested(outStream, functionInfo, funcClass); } catch (IOException e) { @@ -66,6 +65,19 @@ public int execute() throws HiveException { return 0; } + private Description getDescription(Class funcClass) { + if (funcClass == null) { + return null; + } + Description description = AnnotationUtils.getAnnotation(funcClass, Description.class); + if (description != null) { + return description; + } + WindowFunctionDescription windowFunctionDescription = + AnnotationUtils.getAnnotation(funcClass, WindowFunctionDescription.class); + return windowFunctionDescription == null ? null : windowFunctionDescription.description(); + } + private void printBaseInfo(DataOutputStream outStream, String funcName, Class funcClass, Description description) throws IOException, SemanticException { if (funcClass == null) { diff --git ql/src/test/queries/clientpositive/desc_function.q ql/src/test/queries/clientpositive/desc_function.q index d055d9ca03..88cc0b2ab7 100644 --- ql/src/test/queries/clientpositive/desc_function.q +++ ql/src/test/queries/clientpositive/desc_function.q @@ -3,3 +3,6 @@ DESC FUNCTION replace; EXPLAIN DESC FUNCTION EXTENDED replace; DESC FUNCTION EXTENDED replace; + +DESCRIBE FUNCTION dense_rank; +DESCRIBE FUNCTION EXTENDED dense_rank; diff --git ql/src/test/results/clientpositive/desc_function.q.out ql/src/test/results/clientpositive/desc_function.q.out index 1f804bba60..72ef30016f 100644 --- ql/src/test/results/clientpositive/desc_function.q.out +++ ql/src/test/results/clientpositive/desc_function.q.out @@ -51,3 +51,15 @@ Example: 'BLack and BLue' Function class:org.apache.hadoop.hive.ql.udf.UDFReplace Function type:BUILTIN +PREHOOK: query: DESCRIBE FUNCTION dense_rank +PREHOOK: type: DESCFUNCTION +POSTHOOK: query: DESCRIBE FUNCTION dense_rank +POSTHOOK: type: DESCFUNCTION +dense_rank(x) The difference between RANK and DENSE_RANK is that DENSE_RANK leaves no gaps in ranking sequence when there are ties. That is, if you were ranking a competition using DENSE_RANK and had three people tie for second place, you would say that all three were in second place and that the next person came in third. +PREHOOK: query: DESCRIBE FUNCTION EXTENDED dense_rank +PREHOOK: type: DESCFUNCTION +POSTHOOK: query: DESCRIBE FUNCTION EXTENDED dense_rank +POSTHOOK: type: DESCFUNCTION +dense_rank(x) The difference between RANK and DENSE_RANK is that DENSE_RANK leaves no gaps in ranking sequence when there are ties. That is, if you were ranking a competition using DENSE_RANK and had three people tie for second place, you would say that all three were in second place and that the next person came in third. +Function class:org.apache.hadoop.hive.ql.udf.generic.GenericUDAFDenseRank +Function type:BUILTIN