Skip to content

Commit 2cedf2a

Browse files
committed
address comments
1 parent 0b90597 commit 2cedf2a

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

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

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,33 +2134,7 @@ object DatePartLike {
21342134
usage = "_FUNC_(field, source) - Extracts a part of the date/timestamp or interval source.",
21352135
arguments = """
21362136
Arguments:
2137-
* field - selects which part of the source should be extracted.
2138-
- Supported string values of `field` for dates and timestamps are:
2139-
- "MILLENNIUM", ("MILLENNIA", "MIL", "MILS") - the conventional numbering of millennia
2140-
- "CENTURY", ("CENTURIES", "C", "CENT") - the conventional numbering of centuries
2141-
- "DECADE", ("DECADES", "DEC", "DECS") - the year field divided by 1
2142-
- "YEAR", ("Y", "YEARS", "YR", "YRS") - the year field
2143-
- "ISOYEAR" - the ISO 8601 week-numbering year that the datetime falls in
2144-
- "QUARTER", ("QTR") - the quarter (1 - 4) of the year that the datetime falls in
2145-
- "MONTH", ("MON", "MONS", "MONTHS") - the month field
2146-
- "WEEK", ("W", "WEEKS") - the number of the ISO 8601 week-of-week-based-year. A week is considered to start on a Monday and week 1 is the first week with >3 days. In the ISO week-numbering system, it is possible for early-January dates to be part of the 52nd or 53rd week of the previous year, and for late-December dates to be part of the first week of the next year. For example, 2005-01-02 is part of the 53rd week of year 2004, while 2012-12-31 is part of the first week of 2013
2147-
- "DAY", ("D", "DAYS") - the day of the month field (1 - 31)
2148-
- "DAYOFWEEK",("DOW") - the day of the week for datetime as Sunday(1) to Saturday(7)
2149-
- "ISODOW" - ISO 8601 based day of the week for datetime as Monday(1) to Sunday(7)
2150-
- "DOY" - the day of the year (1 - 365/366)
2151-
- "HOUR", ("H", "HOURS", "HR", "HRS") - The hour field (0 - 23)
2152-
- "MINUTE", ("M", "MIN", "MINS", "MINUTES") - the minutes field (0 - 59)
2153-
- "SECOND", ("S", "SEC", "SECONDS", "SECS") - the seconds field, including fractional parts
2154-
- "MILLISECONDS", ("MSEC", "MSECS", "MILLISECON", "MSECONDS", "MS") - the seconds field, including fractional parts, multiplied by 1000. Note that this includes full seconds
2155-
- "MICROSECONDS", ("USEC", "USECS", "USECONDS", "MICROSECON", "US") - The seconds field, including fractional parts, multiplied by 1000000. Note that this includes full seconds
2156-
- "EPOCH" - the number of seconds with fractional part in microsecond precision since 1970-01-01 00:00:00 local time (can be negative)
2157-
- Supported string values of `field` for interval(which consists of `months`, `days`, `microseconds`) are:
2158-
- "YEAR", ("Y", "YEARS", "YR", "YRS") - the total `months` / 12
2159-
- "MONTH", ("MON", "MONS", "MONTHS") - the total `months` modulo 12
2160-
- "DAY", ("D", "DAYS") - the `days` part of interval
2161-
- "HOUR", ("H", "HOURS", "HR", "HRS") - how many hours the `microseconds` contains
2162-
- "MINUTE", ("M", "MIN", "MINS", "MINUTES") - how many minutes left after taking hours from `microseconds`
2163-
- "SECOND", ("S", "SEC", "SECONDS", "SECS") - how many second with fractions left after taking hours and minutes from `microseconds`
2137+
* field - selects which part of the source should be extracted, and supported string values are as same as the fields of the equivalent function `EXTRACT`.
21642138
* source - a date/timestamp or interval column from where `field` should be extracted
21652139
""",
21662140
examples = """
@@ -2179,7 +2153,7 @@ object DatePartLike {
21792153
30.001001
21802154
""",
21812155
note = """
2182-
The _FUNC_ function is equivalent to the SQL-standard function `extract`
2156+
The _FUNC_ function is equivalent to the SQL-standard function `EXTRACT(field FROM source)`
21832157
""",
21842158
since = "3.0.0")
21852159
// scalastyle:on line.size.limit
@@ -2200,8 +2174,33 @@ case class DatePart(field: Expression, source: Expression, child: Expression)
22002174
usage = "_FUNC_(field FROM source) - Extracts a part of the date/timestamp or interval source.",
22012175
arguments = """
22022176
Arguments:
2203-
* field - selects which part of the source should be extracted and supported string values
2204-
are the same with the `date_part` fields.
2177+
* field - selects which part of the source should be extracted
2178+
- Supported string values of `field` for dates and timestamps are:
2179+
- "MILLENNIUM", ("MILLENNIA", "MIL", "MILS") - the conventional numbering of millennia
2180+
- "CENTURY", ("CENTURIES", "C", "CENT") - the conventional numbering of centuries
2181+
- "DECADE", ("DECADES", "DEC", "DECS") - the year field divided by 10
2182+
- "YEAR", ("Y", "YEARS", "YR", "YRS") - the year field
2183+
- "ISOYEAR" - the ISO 8601 week-numbering year that the datetime falls in
2184+
- "QUARTER", ("QTR") - the quarter (1 - 4) of the year that the datetime falls in
2185+
- "MONTH", ("MON", "MONS", "MONTHS") - the month field (1 - 12)
2186+
- "WEEK", ("W", "WEEKS") - the number of the ISO 8601 week-of-week-based-year. A week is considered to start on a Monday and week 1 is the first week with >3 days. In the ISO week-numbering system, it is possible for early-January dates to be part of the 52nd or 53rd week of the previous year, and for late-December dates to be part of the first week of the next year. For example, 2005-01-02 is part of the 53rd week of year 2004, while 2012-12-31 is part of the first week of 2013
2187+
- "DAY", ("D", "DAYS") - the day of the month field (1 - 31)
2188+
- "DAYOFWEEK",("DOW") - the day of the week for datetime as Sunday(1) to Saturday(7)
2189+
- "ISODOW" - ISO 8601 based day of the week for datetime as Monday(1) to Sunday(7)
2190+
- "DOY" - the day of the year (1 - 365/366)
2191+
- "HOUR", ("H", "HOURS", "HR", "HRS") - The hour field (0 - 23)
2192+
- "MINUTE", ("M", "MIN", "MINS", "MINUTES") - the minutes field (0 - 59)
2193+
- "SECOND", ("S", "SEC", "SECONDS", "SECS") - the seconds field, including fractional parts
2194+
- "MILLISECONDS", ("MSEC", "MSECS", "MILLISECON", "MSECONDS", "MS") - the seconds field, including fractional parts, multiplied by 1000. Note that this includes full seconds
2195+
- "MICROSECONDS", ("USEC", "USECS", "USECONDS", "MICROSECON", "US") - The seconds field, including fractional parts, multiplied by 1000000. Note that this includes full seconds
2196+
- "EPOCH" - the number of seconds with fractional part in microsecond precision since 1970-01-01 00:00:00 local time (can be negative)
2197+
- Supported string values of `field` for interval(which consists of `months`, `days`, `microseconds`) are:
2198+
- "YEAR", ("Y", "YEARS", "YR", "YRS") - the total `months` / 12
2199+
- "MONTH", ("MON", "MONS", "MONTHS") - the total `months` % 12
2200+
- "DAY", ("D", "DAYS") - the `days` part of interval
2201+
- "HOUR", ("H", "HOURS", "HR", "HRS") - how many hours the `microseconds` contains
2202+
- "MINUTE", ("M", "MIN", "MINS", "MINUTES") - how many minutes left after taking hours from `microseconds`
2203+
- "SECOND", ("S", "SEC", "SECONDS", "SECS") - how many second with fractions left after taking hours and minutes from `microseconds`
22052204
* source - a date/timestamp or interval column from where `field` should be extracted
22062205
""",
22072206
examples = """
@@ -2220,7 +2219,7 @@ case class DatePart(field: Expression, source: Expression, child: Expression)
22202219
30.001001
22212220
""",
22222221
note = """
2223-
The _FUNC_ function is equivalent to `date_part`.
2222+
The _FUNC_ function is equivalent to `date_part(field, source)`.
22242223
""",
22252224
since = "3.0.0")
22262225
// scalastyle:on line.size.limit

0 commit comments

Comments
 (0)