diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala index 12c24cc768225..319e69c560914 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FunctionRegistry.scala @@ -335,7 +335,8 @@ object FunctionRegistry { val df = clazz.getAnnotation(classOf[ExpressionDescription]) if (df != null) { (name, - (new ExpressionInfo(clazz.getCanonicalName, name, df.usage(), df.extended()), + (new ExpressionInfo( + clazz.getCanonicalName, name, df.usage().stripMargin, df.extended().stripMargin), builder)) } else { (name, (new ExpressionInfo(clazz.getCanonicalName, name), builder)) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala index 741ad1f3efd8a..95b6266f1947f 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala @@ -26,6 +26,10 @@ import org.apache.spark.sql.types._ /** * Given an array or map, returns its size. */ +@ExpressionDescription( + usage = "_FUNC_(column) - Returns the length of the array or map stored in the column", + extended = """> SELECT _FUNC_(array("b", "d", "c", "a")); + | 4""") case class Size(child: Expression) extends UnaryExpression with ExpectsInputTypes { override def dataType: DataType = IntegerType override def inputTypes: Seq[AbstractDataType] = Seq(TypeCollection(ArrayType, MapType)) @@ -44,6 +48,11 @@ case class Size(child: Expression) extends UnaryExpression with ExpectsInputType * Sorts the input array in ascending / descending order according to the natural ordering of * the array elements and returns it. */ +@ExpressionDescription( + usage = """_FUNC_(array, ascendingOrder) - Sorts the input array for the given column in + | ascending / descending order, according to the natural ordering of the array elements""", + extended = """> SELECT _FUNC_(array("b", "d", "c", "a"), false); + | ["d","c","b","a"]""") case class SortArray(base: Expression, ascendingOrder: Expression) extends BinaryExpression with ExpectsInputTypes with CodegenFallback { @@ -125,6 +134,9 @@ case class SortArray(base: Expression, ascendingOrder: Expression) /** * Checks if the array (left) has the element (right) */ +@ExpressionDescription( + usage = "_FUNC_(array, value) - Returns true if the array contains the value", + extended = "> SELECT _FUNC_(array(2, 9, 8), 9);\n true") case class ArrayContains(left: Expression, right: Expression) extends BinaryExpression with ImplicitCastInputTypes { diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/commands.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/commands.scala index e6621e0f50a9e..9666a5b725a46 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/commands.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/commands.scala @@ -28,9 +28,9 @@ import org.apache.spark.sql.types.StringType trait Command /** - * Returned for the "DESCRIBE [EXTENDED] FUNCTION functionName" command. + * Returned for the "DESCRIBE FUNCTION [EXTENDED] functionName" command. * @param functionName The function to be described. - * @param isExtended True if "DESCRIBE EXTENDED" is used. Otherwise, false. + * @param isExtended True if "DESCRIBE FUNCTION EXTENDED" is used. Otherwise, false. */ private[sql] case class DescribeFunction( functionName: String,