Skip to content

Commit e68611a

Browse files
committed
Add a description for DatePart
1 parent af51e52 commit e68611a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,26 @@ case class Decade(child: Expression) extends UnaryExpression with ImplicitCastIn
18771877
}
18781878
}
18791879

1880+
@ExpressionDescription(
1881+
usage = "_FUNC_(field, source) - Extracts a part of the date/timestamp.",
1882+
arguments = """
1883+
Arguments:
1884+
* field - selects which part of the source should be extracted. Supported string values are:
1885+
["MILLENNIUM", "CENTURY", "DECADE", "YEAR", "QUARTER", "MONTH",
1886+
"WEEK", "DAY", "DAYOFWEEK", "DOW", "ISODOW", "DOY",
1887+
"HOUR", "MINUTE", "SECOND"]
1888+
* source - a date (or timestamp) column from where `field` should be extracted
1889+
""",
1890+
examples = """
1891+
Examples:
1892+
> SELECT _FUNC_('YEAR', TIMESTAMP '2019-08-12 01:00:00.123456');
1893+
2019
1894+
> SELECT _FUNC_('week', timestamp'2019-08-12 01:00:00.123456');
1895+
33
1896+
> SELECT _FUNC_('doy', DATE'2019-08-12');
1897+
224
1898+
""",
1899+
since = "3.0.0")
18801900
case class DatePart(field: Expression, source: Expression, child: Expression)
18811901
extends RuntimeReplaceable {
18821902

0 commit comments

Comments
 (0)