Skip to content

Commit 0422ce0

Browse files
HyukjinKwongatorsmile
authored andcommitted
[SPARK-21724][SQL][DOC] Adds since information in the documentation of date functions
## What changes were proposed in this pull request? This PR adds `since` annotation in documentation so that this can be rendered as below: <img width="290" alt="2017-08-14 6 54 26" src="https://user-images.githubusercontent.com/6477701/29267050-034c1f64-8122-11e7-862b-7dfc38e292bf.png"> ## How was this patch tested? Manually checked the documentation by `cd sql && ./create-docs.sh`. Also, Jenkins tests are required. Author: hyukjinkwon <[email protected]> Closes apache#18939 from HyukjinKwon/add-sinces-date-functions.
1 parent 4c3cf1c commit 0422ce0

File tree

1 file changed

+56
-28
lines changed

1 file changed

+56
-28
lines changed

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

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ trait TimeZoneAwareExpression extends Expression {
5353
* There is no code generation since this expression should get constant folded by the optimizer.
5454
*/
5555
@ExpressionDescription(
56-
usage = "_FUNC_() - Returns the current date at the start of query evaluation.")
56+
usage = "_FUNC_() - Returns the current date at the start of query evaluation.",
57+
since = "1.5.0")
5758
case class CurrentDate(timeZoneId: Option[String] = None)
5859
extends LeafExpression with TimeZoneAwareExpression with CodegenFallback {
5960

@@ -81,7 +82,8 @@ case class CurrentDate(timeZoneId: Option[String] = None)
8182
* There is no code generation since this expression should get constant folded by the optimizer.
8283
*/
8384
@ExpressionDescription(
84-
usage = "_FUNC_() - Returns the current timestamp at the start of query evaluation.")
85+
usage = "_FUNC_() - Returns the current timestamp at the start of query evaluation.",
86+
since = "1.5.0")
8587
case class CurrentTimestamp() extends LeafExpression with CodegenFallback {
8688
override def foldable: Boolean = true
8789
override def nullable: Boolean = false
@@ -141,7 +143,8 @@ case class CurrentBatchTimestamp(
141143
Examples:
142144
> SELECT _FUNC_('2016-07-30', 1);
143145
2016-07-31
144-
""")
146+
""",
147+
since = "1.5.0")
145148
case class DateAdd(startDate: Expression, days: Expression)
146149
extends BinaryExpression with ImplicitCastInputTypes {
147150

@@ -174,7 +177,8 @@ case class DateAdd(startDate: Expression, days: Expression)
174177
Examples:
175178
> SELECT _FUNC_('2016-07-30', 1);
176179
2016-07-29
177-
""")
180+
""",
181+
since = "1.5.0")
178182
case class DateSub(startDate: Expression, days: Expression)
179183
extends BinaryExpression with ImplicitCastInputTypes {
180184
override def left: Expression = startDate
@@ -203,7 +207,8 @@ case class DateSub(startDate: Expression, days: Expression)
203207
Examples:
204208
> SELECT _FUNC_('2009-07-30 12:58:59');
205209
12
206-
""")
210+
""",
211+
since = "1.5.0")
207212
case class Hour(child: Expression, timeZoneId: Option[String] = None)
208213
extends UnaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes {
209214

@@ -233,7 +238,8 @@ case class Hour(child: Expression, timeZoneId: Option[String] = None)
233238
Examples:
234239
> SELECT _FUNC_('2009-07-30 12:58:59');
235240
58
236-
""")
241+
""",
242+
since = "1.5.0")
237243
case class Minute(child: Expression, timeZoneId: Option[String] = None)
238244
extends UnaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes {
239245

@@ -263,7 +269,8 @@ case class Minute(child: Expression, timeZoneId: Option[String] = None)
263269
Examples:
264270
> SELECT _FUNC_('2009-07-30 12:58:59');
265271
59
266-
""")
272+
""",
273+
since = "1.5.0")
267274
case class Second(child: Expression, timeZoneId: Option[String] = None)
268275
extends UnaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes {
269276

@@ -293,7 +300,8 @@ case class Second(child: Expression, timeZoneId: Option[String] = None)
293300
Examples:
294301
> SELECT _FUNC_('2016-04-09');
295302
100
296-
""")
303+
""",
304+
since = "1.5.0")
297305
case class DayOfYear(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
298306

299307
override def inputTypes: Seq[AbstractDataType] = Seq(DateType)
@@ -316,7 +324,8 @@ case class DayOfYear(child: Expression) extends UnaryExpression with ImplicitCas
316324
Examples:
317325
> SELECT _FUNC_('2016-07-30');
318326
2016
319-
""")
327+
""",
328+
since = "1.5.0")
320329
case class Year(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
321330

322331
override def inputTypes: Seq[AbstractDataType] = Seq(DateType)
@@ -339,7 +348,8 @@ case class Year(child: Expression) extends UnaryExpression with ImplicitCastInpu
339348
Examples:
340349
> SELECT _FUNC_('2016-08-31');
341350
3
342-
""")
351+
""",
352+
since = "1.5.0")
343353
case class Quarter(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
344354

345355
override def inputTypes: Seq[AbstractDataType] = Seq(DateType)
@@ -362,7 +372,8 @@ case class Quarter(child: Expression) extends UnaryExpression with ImplicitCastI
362372
Examples:
363373
> SELECT _FUNC_('2016-07-30');
364374
7
365-
""")
375+
""",
376+
since = "1.5.0")
366377
case class Month(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
367378

368379
override def inputTypes: Seq[AbstractDataType] = Seq(DateType)
@@ -385,7 +396,8 @@ case class Month(child: Expression) extends UnaryExpression with ImplicitCastInp
385396
Examples:
386397
> SELECT _FUNC_('2009-07-30');
387398
30
388-
""")
399+
""",
400+
since = "1.5.0")
389401
case class DayOfMonth(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
390402

391403
override def inputTypes: Seq[AbstractDataType] = Seq(DateType)
@@ -409,7 +421,8 @@ case class DayOfMonth(child: Expression) extends UnaryExpression with ImplicitCa
409421
Examples:
410422
> SELECT _FUNC_('2009-07-30');
411423
5
412-
""")
424+
""",
425+
since = "2.3.0")
413426
// scalastyle:on line.size.limit
414427
case class DayOfWeek(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
415428

@@ -447,7 +460,8 @@ case class DayOfWeek(child: Expression) extends UnaryExpression with ImplicitCas
447460
Examples:
448461
> SELECT _FUNC_('2008-02-20');
449462
8
450-
""")
463+
""",
464+
since = "1.5.0")
451465
// scalastyle:on line.size.limit
452466
case class WeekOfYear(child: Expression) extends UnaryExpression with ImplicitCastInputTypes {
453467

@@ -493,7 +507,8 @@ case class WeekOfYear(child: Expression) extends UnaryExpression with ImplicitCa
493507
Examples:
494508
> SELECT _FUNC_('2016-04-08', 'y');
495509
2016
496-
""")
510+
""",
511+
since = "1.5.0")
497512
// scalastyle:on line.size.limit
498513
case class DateFormatClass(left: Expression, right: Expression, timeZoneId: Option[String] = None)
499514
extends BinaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes {
@@ -534,7 +549,8 @@ case class DateFormatClass(left: Expression, right: Expression, timeZoneId: Opti
534549
Examples:
535550
> SELECT _FUNC_('2016-04-08', 'yyyy-MM-dd');
536551
1460041200
537-
""")
552+
""",
553+
since = "1.6.0")
538554
case class ToUnixTimestamp(
539555
timeExp: Expression,
540556
format: Expression,
@@ -574,7 +590,8 @@ case class ToUnixTimestamp(
574590
1476884637
575591
> SELECT _FUNC_('2016-04-08', 'yyyy-MM-dd');
576592
1460041200
577-
""")
593+
""",
594+
since = "1.5.0")
578595
case class UnixTimestamp(timeExp: Expression, format: Expression, timeZoneId: Option[String] = None)
579596
extends UnixTime {
580597

@@ -724,7 +741,8 @@ abstract class UnixTime
724741
Examples:
725742
> SELECT _FUNC_(0, 'yyyy-MM-dd HH:mm:ss');
726743
1970-01-01 00:00:00
727-
""")
744+
""",
745+
since = "1.5.0")
728746
case class FromUnixTime(sec: Expression, format: Expression, timeZoneId: Option[String] = None)
729747
extends BinaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes {
730748

@@ -833,7 +851,8 @@ case class FromUnixTime(sec: Expression, format: Expression, timeZoneId: Option[
833851
Examples:
834852
> SELECT _FUNC_('2009-01-12');
835853
2009-01-31
836-
""")
854+
""",
855+
since = "1.5.0")
837856
case class LastDay(startDate: Expression) extends UnaryExpression with ImplicitCastInputTypes {
838857
override def child: Expression = startDate
839858

@@ -867,7 +886,8 @@ case class LastDay(startDate: Expression) extends UnaryExpression with ImplicitC
867886
Examples:
868887
> SELECT _FUNC_('2015-01-14', 'TU');
869888
2015-01-20
870-
""")
889+
""",
890+
since = "1.5.0")
871891
// scalastyle:on line.size.limit
872892
case class NextDay(startDate: Expression, dayOfWeek: Expression)
873893
extends BinaryExpression with ImplicitCastInputTypes {
@@ -968,7 +988,8 @@ case class TimeAdd(start: Expression, interval: Expression, timeZoneId: Option[S
968988
Examples:
969989
> SELECT from_utc_timestamp('2016-08-31', 'Asia/Seoul');
970990
2016-08-31 09:00:00
971-
""")
991+
""",
992+
since = "1.5.0")
972993
// scalastyle:on line.size.limit
973994
case class FromUTCTimestamp(left: Expression, right: Expression)
974995
extends BinaryExpression with ImplicitCastInputTypes {
@@ -1061,7 +1082,8 @@ case class TimeSub(start: Expression, interval: Expression, timeZoneId: Option[S
10611082
Examples:
10621083
> SELECT _FUNC_('2016-08-31', 1);
10631084
2016-09-30
1064-
""")
1085+
""",
1086+
since = "1.5.0")
10651087
// scalastyle:on line.size.limit
10661088
case class AddMonths(startDate: Expression, numMonths: Expression)
10671089
extends BinaryExpression with ImplicitCastInputTypes {
@@ -1097,7 +1119,8 @@ case class AddMonths(startDate: Expression, numMonths: Expression)
10971119
Examples:
10981120
> SELECT _FUNC_('1997-02-28 10:30:00', '1996-10-30');
10991121
3.94959677
1100-
""")
1122+
""",
1123+
since = "1.5.0")
11011124
// scalastyle:on line.size.limit
11021125
case class MonthsBetween(date1: Expression, date2: Expression, timeZoneId: Option[String] = None)
11031126
extends BinaryExpression with TimeZoneAwareExpression with ImplicitCastInputTypes {
@@ -1140,7 +1163,8 @@ case class MonthsBetween(date1: Expression, date2: Expression, timeZoneId: Optio
11401163
Examples:
11411164
> SELECT _FUNC_('2016-08-31', 'Asia/Seoul');
11421165
2016-08-30 15:00:00
1143-
""")
1166+
""",
1167+
since = "1.5.0")
11441168
// scalastyle:on line.size.limit
11451169
case class ToUTCTimestamp(left: Expression, right: Expression)
11461170
extends BinaryExpression with ImplicitCastInputTypes {
@@ -1203,7 +1227,8 @@ case class ToUTCTimestamp(left: Expression, right: Expression)
12031227
2009-07-30
12041228
> SELECT _FUNC_('2016-12-31', 'yyyy-MM-dd');
12051229
2016-12-31
1206-
""")
1230+
""",
1231+
since = "1.5.0")
12071232
case class ParseToDate(left: Expression, format: Option[Expression], child: Expression)
12081233
extends RuntimeReplaceable {
12091234

@@ -1244,7 +1269,8 @@ case class ParseToDate(left: Expression, format: Option[Expression], child: Expr
12441269
2016-12-31 00:12:00
12451270
> SELECT _FUNC_('2016-12-31', 'yyyy-MM-dd');
12461271
2016-12-31 00:00:00
1247-
""")
1272+
""",
1273+
since = "2.2.0")
12481274
case class ParseToTimestamp(left: Expression, format: Option[Expression], child: Expression)
12491275
extends RuntimeReplaceable {
12501276

@@ -1279,7 +1305,8 @@ case class ParseToTimestamp(left: Expression, format: Option[Expression], child:
12791305
2009-02-01
12801306
> SELECT _FUNC_('2015-10-27', 'YEAR');
12811307
2015-01-01
1282-
""")
1308+
""",
1309+
since = "1.5.0")
12831310
// scalastyle:on line.size.limit
12841311
case class TruncDate(date: Expression, format: Expression)
12851312
extends BinaryExpression with ImplicitCastInputTypes {
@@ -1359,7 +1386,8 @@ case class TruncDate(date: Expression, format: Expression)
13591386
13601387
> SELECT _FUNC_('2009-07-30', '2009-07-31');
13611388
-1
1362-
""")
1389+
""",
1390+
since = "1.5.0")
13631391
case class DateDiff(endDate: Expression, startDate: Expression)
13641392
extends BinaryExpression with ImplicitCastInputTypes {
13651393

0 commit comments

Comments
 (0)