Skip to content

Commit 128bcad

Browse files
jaceklaskowskiliyichao
authored andcommitted
[MINOR][SQL][DOCS] Improve unix_timestamp's scaladoc (and typo hunting)
## What changes were proposed in this pull request? * Docs are consistent (across different `unix_timestamp` variants and their internal expressions) * typo hunting ## How was this patch tested? local build Author: Jacek Laskowski <jacek@japila.pl> Closes apache#17801 from jaceklaskowski/unix_timestamp.
1 parent b254568 commit 128bcad

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ case class DateFormatClass(left: Expression, right: Expression, timeZoneId: Opti
488488
* Deterministic version of [[UnixTimestamp]], must have at least one parameter.
489489
*/
490490
@ExpressionDescription(
491-
usage = "_FUNC_(expr[, pattern]) - Returns the UNIX timestamp of the give time.",
491+
usage = "_FUNC_(expr[, pattern]) - Returns the UNIX timestamp of the given time.",
492492
extended = """
493493
Examples:
494494
> SELECT _FUNC_('2016-04-08', 'yyyy-MM-dd');
@@ -1225,8 +1225,8 @@ case class ParseToTimestamp(left: Expression, format: Expression, child: Express
12251225
extends RuntimeReplaceable {
12261226

12271227
def this(left: Expression, format: Expression) = {
1228-
this(left, format, Cast(UnixTimestamp(left, format), TimestampType))
1229-
}
1228+
this(left, format, Cast(UnixTimestamp(left, format), TimestampType))
1229+
}
12301230

12311231
override def flatArguments: Iterator[Any] = Iterator(left, format)
12321232
override def sql: String = s"$prettyName(${left.sql}, ${format.sql})"

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ object DateTimeUtils {
423423
}
424424

425425
/**
426-
* Parses a given UTF8 date string to the corresponding a corresponding [[Int]] value.
426+
* Parses a given UTF8 date string to a corresponding [[Int]] value.
427427
* The return type is [[Option]] in order to distinguish between 0 and null. The following
428428
* formats are allowed:
429429
*

sql/core/src/main/scala/org/apache/spark/sql/functions.scala

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,10 +2491,10 @@ object functions {
24912491
* Converts a date/timestamp/string to a value of string in the format specified by the date
24922492
* format given by the second argument.
24932493
*
2494-
* A pattern could be for instance `dd.MM.yyyy` and could return a string like '18.03.1993'. All
2495-
* pattern letters of `java.text.SimpleDateFormat` can be used.
2494+
* A pattern `dd.MM.yyyy` would return a string like `18.03.1993`.
2495+
* All pattern letters of `java.text.SimpleDateFormat` can be used.
24962496
*
2497-
* @note Use when ever possible specialized functions like [[year]]. These benefit from a
2497+
* @note Use specialized functions like [[year]] whenever possible as they benefit from a
24982498
* specialized implementation.
24992499
*
25002500
* @group datetime_funcs
@@ -2647,7 +2647,11 @@ object functions {
26472647
}
26482648

26492649
/**
2650-
* Gets current Unix timestamp in seconds.
2650+
* Returns the current Unix timestamp (in seconds).
2651+
*
2652+
* @note All calls of `unix_timestamp` within the same query return the same value
2653+
* (i.e. the current timestamp is calculated at the start of query evaluation).
2654+
*
26512655
* @group datetime_funcs
26522656
* @since 1.5.0
26532657
*/
@@ -2657,7 +2661,9 @@ object functions {
26572661

26582662
/**
26592663
* Converts time string in format yyyy-MM-dd HH:mm:ss to Unix timestamp (in seconds),
2660-
* using the default timezone and the default locale, return null if fail.
2664+
* using the default timezone and the default locale.
2665+
* Returns `null` if fails.
2666+
*
26612667
* @group datetime_funcs
26622668
* @since 1.5.0
26632669
*/
@@ -2666,13 +2672,15 @@ object functions {
26662672
}
26672673

26682674
/**
2669-
* Convert time string with given pattern
2670-
* (see [http://docs.oracle.com/javase/tutorial/i18n/format/simpleDateFormat.html])
2671-
* to Unix time stamp (in seconds), return null if fail.
2675+
* Converts time string with given pattern to Unix timestamp (in seconds).
2676+
* Returns `null` if fails.
2677+
*
2678+
* @see <a href="http://docs.oracle.com/javase/tutorial/i18n/format/simpleDateFormat.html">
2679+
* Customizing Formats</a>
26722680
* @group datetime_funcs
26732681
* @since 1.5.0
26742682
*/
2675-
def unix_timestamp(s: Column, p: String): Column = withExpr {UnixTimestamp(s.expr, Literal(p)) }
2683+
def unix_timestamp(s: Column, p: String): Column = withExpr { UnixTimestamp(s.expr, Literal(p)) }
26762684

26772685
/**
26782686
* Convert time string to a Unix timestamp (in seconds).

0 commit comments

Comments
 (0)