diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/First.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/First.scala index d702c08cfd34..6c9b7d559c3e 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/First.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/First.scala @@ -29,9 +29,14 @@ import org.apache.spark.sql.types._ * a single partition, and we use a single reducer to do the aggregation.). */ @ExpressionDescription( - usage = """_FUNC_(expr) - Returns the first value of `child` for a group of rows. - _FUNC_(expr,isIgnoreNull=false) - Returns the first value of `child` for a group of rows. + usage = + """ + _FUNC_(expr) - Returns the first value of `child` for a group of rows. + + _FUNC_(expr, isIgnoreNull=false) - Returns the first value of `child` for a group of rows. If isIgnoreNull is true, returns only non-null values. + + Note that in most cases the result is nondeterministic. """) case class First(child: Expression, ignoreNullsExpr: Expression) extends DeclarativeAggregate { diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Last.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Last.scala index 8579f7292d3a..b8453f79f48a 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Last.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Last.scala @@ -29,7 +29,15 @@ import org.apache.spark.sql.types._ * a single partition, and we use a single reducer to do the aggregation.). */ @ExpressionDescription( - usage = "_FUNC_(expr,isIgnoreNull) - Returns the last value of `child` for a group of rows.") + usage = + """ + _FUNC_(expr) - Returns the last value of `child` for a group of rows. + + _FUNC_(expr, isIgnoreNull) - Returns the last value of `child` for a group of rows. + If isIgnoreNull is true, returns only non-null values. + + Note that in most cases the result is nondeterministic. + """) case class Last(child: Expression, ignoreNullsExpr: Expression) extends DeclarativeAggregate { def this(child: Expression) = this(child, Literal.create(false, BooleanType)) @@ -37,7 +45,7 @@ case class Last(child: Expression, ignoreNullsExpr: Expression) extends Declarat private val ignoreNulls: Boolean = ignoreNullsExpr match { case Literal(b: Boolean, BooleanType) => b case _ => - throw new AnalysisException("The second argument of First should be a boolean literal.") + throw new AnalysisException("The second argument of Last should be a boolean literal.") } override def children: Seq[Expression] = child :: ignoreNullsExpr :: Nil