From f6a7060be07eaa80ffb07fcb4751935a0b9e1e44 Mon Sep 17 00:00:00 2001 From: Maxim Gekk Date: Sun, 2 Feb 2020 23:10:07 +0300 Subject: [PATCH 1/2] Fix to_timestamp description --- .../sql/catalyst/expressions/datetimeExpressions.scala | 2 +- .../src/main/scala/org/apache/spark/sql/functions.scala | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala index 8b3f53228f5f..81b7203d7efe 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala @@ -1370,7 +1370,7 @@ case class ParseToDate(left: Expression, format: Option[Expression], child: Expr } /** - * Parses a column to a timestamp based on the supplied format. + * Parses a column to a timestamp in the seconds precision based on the supplied format. */ @ExpressionDescription( usage = """ diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala index f059add514e5..0364832cdae9 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala @@ -2949,10 +2949,10 @@ object functions { def unix_timestamp(s: Column, p: String): Column = withExpr { UnixTimestamp(s.expr, Literal(p)) } /** - * Converts to a timestamp by casting rules to `TimestampType`. + * Converts to a timestamp by casting rules to `TimestampType` in the seconds precision. * * @param s A date, timestamp or string. If a string, the data must be in a format that can be - * cast to a timestamp, such as `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss.SSSS` + * cast to a timestamp, such as `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss` * @return A timestamp, or null if the input was a string that could not be cast to a timestamp * @group datetime_funcs * @since 2.2.0 @@ -2962,12 +2962,12 @@ object functions { } /** - * Converts time string with the given pattern to timestamp. + * Converts time string with the given pattern to timestamp in the seconds precision. * * See [[java.text.SimpleDateFormat]] for valid date and time format patterns * * @param s A date, timestamp or string. If a string, the data must be in a format that can be - * cast to a timestamp, such as `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss.SSSS` + * cast to a timestamp, such as `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss` * @param fmt A date time pattern detailing the format of `s` when `s` is a string * @return A timestamp, or null if `s` was a string that could not be cast to a timestamp or * `fmt` was an invalid format From c7f75a95bc18886161f2986d10ddcfa729755b86 Mon Sep 17 00:00:00 2001 From: Maxim Gekk Date: Mon, 3 Feb 2020 11:23:02 +0300 Subject: [PATCH 2/2] Remove `seconds precision` --- .../sql/catalyst/expressions/datetimeExpressions.scala | 2 +- .../src/main/scala/org/apache/spark/sql/functions.scala | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala index 81b7203d7efe..8b3f53228f5f 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala @@ -1370,7 +1370,7 @@ case class ParseToDate(left: Expression, format: Option[Expression], child: Expr } /** - * Parses a column to a timestamp in the seconds precision based on the supplied format. + * Parses a column to a timestamp based on the supplied format. */ @ExpressionDescription( usage = """ diff --git a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala index 0364832cdae9..f419a385983e 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/functions.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/functions.scala @@ -2949,10 +2949,10 @@ object functions { def unix_timestamp(s: Column, p: String): Column = withExpr { UnixTimestamp(s.expr, Literal(p)) } /** - * Converts to a timestamp by casting rules to `TimestampType` in the seconds precision. + * Converts to a timestamp by casting rules to `TimestampType`. * * @param s A date, timestamp or string. If a string, the data must be in a format that can be - * cast to a timestamp, such as `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss` + * cast to a timestamp, such as `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss.SSSS` * @return A timestamp, or null if the input was a string that could not be cast to a timestamp * @group datetime_funcs * @since 2.2.0 @@ -2962,7 +2962,7 @@ object functions { } /** - * Converts time string with the given pattern to timestamp in the seconds precision. + * Converts time string with the given pattern to timestamp. * * See [[java.text.SimpleDateFormat]] for valid date and time format patterns *