yaooqinn commented on issue #28248: URL: https://github.com/apache/spark/pull/28248#issuecomment-616281300
@dongjoon-hyun thanks for checking the `describe function` command. It seems that `*/-` with proper intentions can let us have it in both ways - in SQL command and SQL doc. Please check the result below to see whether you are satisfied with.  ```sql +-- !query +DESC FUNCTION EXTENDED date_part +-- !query schema +struct<function_desc:string> +-- !query output +Class: org.apache.spark.sql.catalyst.expressions.DatePart +Extended Usage: + Arguments: + * field - selects which part of the source should be extracted. + - Supported string values of `field` for dates and timestamps are: + - "MILLENNIUM", ("MILLENNIA", "MIL", "MILS") - the conventional numbering of millennia + - "CENTURY", ("CENTURIES", "C", "CENT") - the conventional numbering of centuries + - "DECADE", ("DECADES", "DEC", "DECS") - the year field divided by 1 + - "YEAR", ("Y", "YEARS", "YR", "YRS") - the year field + - "ISOYEAR" - the ISO 8601 week-numbering year that the datetime falls in + - "QUARTER", ("QTR") - the quarter (1 - 4) of the year that the datetime falls in + - "MONTH", ("MON", "MONS", "MONTHS") - the month field + - "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 + - "DAY", ("D", "DAYS") - the day of the month field (1 - 31) + - "DAYOFWEEK",("DOW") - the day of the week for datetime as Sunday(1) to Saturday(7) + - "ISODOW" - ISO 8601 based day of the week for datetime as Monday(1) to Sunday(7) + - "DOY" - the day of the year (1 - 365/366) + - "HOUR", ("H", "HOURS", "HR", "HRS") - The hour field (0 - 23) + - "MINUTE", ("M", "MIN", "MINS", "MINUTES") - the minutes field (0 - 59) + - "SECOND", ("S", "SEC", "SECONDS", "SECS") - the seconds field, including fractional parts + - "MILLISECONDS", ("MSEC", "MSECS", "MILLISECON", "MSECONDS", "MS") - the seconds field, including fractional parts, multiplied by 1000. Note that this includes full seconds + - "MICROSECONDS", ("USEC", "USECS", "USECONDS", "MICROSECON", "US") - The seconds field, including fractional parts, multiplied by 1000000. Note that this includes full seconds + - "EPOCH" - the number of seconds with fractional part in microsecond precision since 1970-01-01 00:00:00 local time (can be negative) + - Supported string values of `field` for interval(which consists of `months`, `days`, `microseconds`) are: + - "YEAR", ("Y", "YEARS", "YR", "YRS") - the total `months` / 12 + - "MONTH", ("MON", "MONS", "MONTHS") - the total `months` modulo 12 + - "DAY", ("D", "DAYS") - the `days` part of interval + - "HOUR", ("H", "HOURS", "HR", "HRS") - how many hours the `microseconds` contains + - "MINUTE", ("M", "MIN", "MINS", "MINUTES") - how many minutes left after taking hours from `microseconds` + - "SECOND", ("S", "SEC", "SECONDS", "SECS") - how many second with fractions left after taking hours and minutes from `microseconds` + * source - a date/timestamp or interval column from where `field` should be extracted + + Examples: + > SELECT date_part('YEAR', TIMESTAMP '2019-08-12 01:00:00.123456'); + 2019 + > SELECT date_part('week', timestamp'2019-08-12 01:00:00.123456'); + 33 + > SELECT date_part('doy', DATE'2019-08-12'); + 224 + > SELECT date_part('SECONDS', timestamp'2019-10-01 00:00:01.000001'); + 1.000001 + > SELECT date_part('days', interval 1 year 10 months 5 days); + 5 + > SELECT date_part('seconds', interval 5 hours 30 seconds 1 milliseconds 1 microseconds); + 30.001001 + + Note: + The date_part function is equivalent to the SQL-standard function `extract` + + Since: 3.0.0 + +Function: date_part +Usage: date_part(field, source) - Extracts a part of the date/timestamp or interval source. ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
