You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
+30-31Lines changed: 30 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -2134,33 +2134,7 @@ object DatePartLike {
2134
2134
usage ="_FUNC_(field, source) - Extracts a part of the date/timestamp or interval source.",
2135
2135
arguments ="""
2136
2136
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`.
2164
2138
* source - a date/timestamp or interval column from where `field` should be extracted
2165
2139
""",
2166
2140
examples ="""
@@ -2179,7 +2153,7 @@ object DatePartLike {
2179
2153
30.001001
2180
2154
""",
2181
2155
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)`
2183
2157
""",
2184
2158
since ="3.0.0")
2185
2159
// scalastyle:on line.size.limit
@@ -2200,8 +2174,33 @@ case class DatePart(field: Expression, source: Expression, child: Expression)
2200
2174
usage ="_FUNC_(field FROM source) - Extracts a part of the date/timestamp or interval source.",
2201
2175
arguments ="""
2202
2176
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`
2205
2204
* source - a date/timestamp or interval column from where `field` should be extracted
2206
2205
""",
2207
2206
examples ="""
@@ -2220,7 +2219,7 @@ case class DatePart(field: Expression, source: Expression, child: Expression)
2220
2219
30.001001
2221
2220
""",
2222
2221
note ="""
2223
-
The _FUNC_ function is equivalent to `date_part`.
2222
+
The _FUNC_ function is equivalent to `date_part(field, source)`.
0 commit comments