-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-17963][SQL][Documentation] Add examples (extend) in each expression and improve documentation with arguments #15513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
5f70b1d
77abafa
8cd6d80
2614572
29d0262
710c68e
1d44ec3
78b1fc7
e2062af
e9672db
9baa847
fff85f6
2462775
10892fb
45e7f99
1d69e40
9b24e78
ed1c839
1535186
8efee7e
a111d2a
a8ddcc2
99b5658
a29472e
73ccda0
d927bff
91d2ab5
7841860
01eecfe
1979d92
d56ac66
8a773d4
f71e39e
caa71c8
5163a87
f8d11aa
da40f85
feafdc2
2656c62
15c02ca
035baef
c55ecb6
ad7b71d
3965d00
498d69c
400cee5
2b437fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…ent names
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,10 +145,10 @@ case class DateSub(startDate: Expression, days: Expression) | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the hour component of the string/timestamp/interval.", | ||
| usage = "_FUNC_(timestamp) - Returns the hour component of the string/timestamp/interval.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a timestamp expression. | ||
| timestamp - a timestamp expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2009-07-30 12:58:59'); | ||
|
|
@@ -171,10 +171,10 @@ case class Hour(child: Expression) extends UnaryExpression with ImplicitCastInpu | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the minute component of the string/timestamp/interval.", | ||
| usage = "_FUNC_(timestamp) - Returns the minute component of the string/timestamp/interval.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a timestamp expression. | ||
| timestamp - a timestamp expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2009-07-30 12:58:59'); | ||
|
|
@@ -197,10 +197,10 @@ case class Minute(child: Expression) extends UnaryExpression with ImplicitCastIn | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the second component of the string/timestamp/interval.", | ||
| usage = "_FUNC_(timestamp) - Returns the second component of the string/timestamp/interval.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a timestamp expression. | ||
| timestamp - a timestamp expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2009-07-30 12:58:59'); | ||
|
|
@@ -223,10 +223,10 @@ case class Second(child: Expression) extends UnaryExpression with ImplicitCastIn | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the day of year of date/timestamp.", | ||
| usage = "_FUNC_(date) - Returns the day of year of date/timestamp.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a date expression. | ||
| date - a date expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2016-04-09'); | ||
|
|
@@ -249,10 +249,10 @@ case class DayOfYear(child: Expression) extends UnaryExpression with ImplicitCas | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the year component of the date/timestamp/interval.", | ||
| usage = "_FUNC_(date) - Returns the year component of the date/timestamp/interval.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a date expression. | ||
| date - a date expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2016-07-30'); | ||
|
|
@@ -275,10 +275,10 @@ case class Year(child: Expression) extends UnaryExpression with ImplicitCastInpu | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the quarter of the year for date, in the range 1 to 4.", | ||
| usage = "_FUNC_(date) - Returns the quarter of the year for date, in the range 1 to 4.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a date expression. | ||
| date - a date expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2016-08-31'); | ||
|
|
@@ -301,10 +301,10 @@ case class Quarter(child: Expression) extends UnaryExpression with ImplicitCastI | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the month component of the date/timestamp/interval.", | ||
| usage = "_FUNC_(date) - Returns the month component of the date/timestamp/interval.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a date expression. | ||
| date - a date expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2016-07-30'); | ||
|
|
@@ -327,10 +327,10 @@ case class Month(child: Expression) extends UnaryExpression with ImplicitCastInp | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the day of month of date/timestamp, or the day of interval.", | ||
| usage = "_FUNC_(date) - Returns the day of month of date/timestamp, or the day of interval.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a date expression. | ||
| date - a date expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2009-07-30'); | ||
|
|
@@ -353,10 +353,10 @@ case class DayOfMonth(child: Expression) extends UnaryExpression with ImplicitCa | |
| } | ||
|
|
||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the week of the year of the given date.", | ||
| usage = "_FUNC_(date) - Returns the week of the year of the given date.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a date expression. | ||
| date - a date expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2008-02-20'); | ||
|
|
@@ -400,10 +400,10 @@ case class WeekOfYear(child: Expression) extends UnaryExpression with ImplicitCa | |
|
|
||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr, fmt) - Converts expr to a value of string in the format specified by the date format fmt.", | ||
| usage = "_FUNC_(timestamp, fmt) - Converts expr to a value of string in the format specified by the date format fmt.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a timestamp expression. | ||
| timestamp - a timestamp expression. | ||
| fmt - string type expression that represents date/timestamp format used in java.text.SimpleDateFormat. | ||
|
|
||
| Examples: | ||
|
|
@@ -705,10 +705,10 @@ case class FromUnixTime(sec: Expression, format: Expression) | |
| * Returns the last day of the month which the date belongs to. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Returns the last day of the month which the date belongs to.", | ||
| usage = "_FUNC_(date) - Returns the last day of the month which the date belongs to.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a date expression. | ||
| date - a date expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2009-01-12'); | ||
|
|
@@ -842,10 +842,10 @@ case class TimeAdd(start: Expression, interval: Expression) | |
| */ | ||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr, timezone) - Assumes given timestamp is UTC and converts to given timezone.", | ||
| usage = "_FUNC_(timestamp, timezone) - Assumes given timestamp is UTC and converts to given timezone.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a timestamp expression. | ||
| timestamp - a timestamp expression. | ||
| timezone - a string expression that represents time zone (e.g., 'Asia/Seoul'). | ||
|
|
||
| Examples: | ||
|
|
@@ -969,11 +969,11 @@ case class AddMonths(startDate: Expression, numMonths: Expression) | |
| * Returns number of months between dates date1 and date2. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr1, expr2) - Returns number of months between dates expr1 and expr2.", | ||
| usage = "_FUNC_(timestamp1, timestamp2) - Returns number of months between dates expr1 and expr2.", | ||
| extended = """ | ||
| Arguments: | ||
| expr1 - a timestamp expression. | ||
| expr2 - a timestamp expression. | ||
| timestamp1 - a timestamp expression. | ||
| timestamp2 - a timestamp expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('1997-02-28 10:30:00', '1996-10-30'); | ||
|
|
@@ -1008,10 +1008,10 @@ case class MonthsBetween(date1: Expression, date2: Expression) | |
| */ | ||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr, timezone) - Assumes given timestamp is in given timezone and converts to UTC.", | ||
| usage = "_FUNC_(timestamp, timezone) - Assumes given timestamp is in given timezone and converts to UTC.", | ||
|
||
| extended = """ | ||
| Arguments: | ||
| expr - a timestamp expression. | ||
| timestamp - a timestamp expression. | ||
| timezone - a string expression that represents time zone (e.g., 'Asia/Seoul'). | ||
|
|
||
| Examples: | ||
|
|
@@ -1068,10 +1068,10 @@ case class ToUTCTimestamp(left: Expression, right: Expression) | |
| * Returns the date part of a timestamp or string. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr) - Extracts the date part of the date or datetime expression expr.", | ||
| usage = "_FUNC_(date) - Extracts the date part of the date or datetime expression expr.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a date expression. | ||
| date - a date expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2009-07-30 04:17:52'); | ||
|
|
@@ -1099,10 +1099,10 @@ case class ToDate(child: Expression) extends UnaryExpression with ImplicitCastIn | |
| */ | ||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr, fmt) - Returns returns date with the time portion of the day truncated to the unit specified by the format model fmt.", | ||
| usage = "_FUNC_(date, fmt) - Returns returns date with the time portion of the day truncated to the unit specified by the format model fmt.", | ||
| extended = """ | ||
| Arguments: | ||
| expr - a date expression. | ||
| date - a date expression. | ||
| fmt - a string expression that represents the truncate level. Available values are "YEAR", "YYYY", "YY", "MON", "MONTH" and "MM". | ||
|
|
||
| Examples: | ||
|
|
@@ -1182,11 +1182,11 @@ case class TruncDate(date: Expression, format: Expression) | |
| * Returns the number of days from startDate to endDate. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr1, expr2) - Returns the number of days between expr1 and expr2.", | ||
| usage = "_FUNC_(date1, date2) - Returns the number of days between expr1 and expr2.", | ||
| extended = """ | ||
| Arguments: | ||
| expr1 - a date expression. | ||
| expr2 - a date expression. | ||
| date1 - a date expression. | ||
| date2 - a date expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_('2009-07-30', '2009-07-31'); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -872,11 +872,11 @@ case class Pow(left: Expression, right: Expression) | |
| * @param right number of bits to left shift. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr1, expr2) - Bitwise left shift.", | ||
| usage = "_FUNC_(base, expr) - Bitwise left shift.", | ||
| extended = """ | ||
| Arguments: | ||
| expr1 - a numeric expression. | ||
| expr2 - a numeric expression. | ||
| base - a numeric expression that defines the base number to shift. | ||
| expr - a numeric expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_(2, 1); | ||
|
|
@@ -909,11 +909,11 @@ case class ShiftLeft(left: Expression, right: Expression) | |
| * @param right number of bits to right shift. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr1, expr2) - Bitwise right shift.", | ||
| usage = "_FUNC_(base, expr) - Bitwise right shift.", | ||
|
||
| extended = """ | ||
| Arguments: | ||
| expr1 - a numeric expression. | ||
| expr2 - a numeric expression. | ||
| base - a numeric expression that defines the base number to shift. | ||
| expr - a numeric expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_(4, 1); | ||
|
|
@@ -946,11 +946,11 @@ case class ShiftRight(left: Expression, right: Expression) | |
| * @param right the number of bits to right shift. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr1, expr2) - Bitwise unsigned right shift.", | ||
| usage = "_FUNC_(base, expr) - Bitwise unsigned right shift.", | ||
| extended = """ | ||
| Arguments: | ||
| expr1 - a numeric expression. | ||
| expr2 - a numeric expression. | ||
| base - a numeric expression that defines the base number to shift. | ||
| expr - a numeric expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_(4, 1); | ||
|
|
@@ -998,11 +998,11 @@ case class Hypot(left: Expression, right: Expression) | |
| * @param right the number to compute the logarithm of. | ||
| */ | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr1, expr2) - Returns the logarithm of expr1 with base expr2.", | ||
| usage = "_FUNC_(base, expr) - Returns the logarithm of expr with base.", | ||
| extended = """ | ||
| Arguments: | ||
| expr1 - a numeric expression. | ||
| expr2 - a numeric expression. | ||
| base - a numeric expression that represents the logarithm base. | ||
| expr - a numeric expression. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_(10, 100); | ||
|
|
@@ -1232,11 +1232,11 @@ abstract class RoundBase(child: Expression, scale: Expression, | |
| */ | ||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr1, expr2) - Round expr1 to expr2 decimal places using HALF_UP rounding mode.", | ||
| usage = "_FUNC_(expr, d) - Round expr to d decimal places using HALF_UP rounding mode.", | ||
| extended = """ | ||
| Arguments: | ||
| expr1 - a numeric expression. | ||
| expr2 - a numeric expression. | ||
| expr - a numeric expression. | ||
| d - a numeric expression that defines tge decimal places using HALF_UP rounding mode. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_(2.5, 0); | ||
|
|
@@ -1256,11 +1256,11 @@ case class Round(child: Expression, scale: Expression) | |
| */ | ||
| // scalastyle:off line.size.limit | ||
| @ExpressionDescription( | ||
| usage = "_FUNC_(expr1, expr2) - Round expr1 to expr2 decimal places using HALF_EVEN rounding mode.", | ||
| usage = "_FUNC_(expr, d) - Round expr to d decimal places using HALF_EVEN rounding mode.", | ||
|
||
| extended = """ | ||
| Arguments: | ||
| expr1 - a numeric expression. | ||
| expr2 - a numeric expression. | ||
| expr - a numeric expression. | ||
| d - a numeric expression that defines decimal places using HALF_EVEN rounding mode. | ||
|
|
||
| Examples: | ||
| > SELECT _FUNC_(2.5, 0); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recently ran into this function in https://issues.apache.org/jira/browse/SPARK-17971?focusedCommentId=15583676&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-15583676 and found its behavior pretty confusing. If you're willing, maybe a couple sentences here and in "to_unix_timestamp" could help clarify, because, timestamps actually have no timezone.
I think I'd describe this as:
Given a timestamp, which corresponds to a certain time of day in UTC, returns another timestamp that corresponds to the same time of day in the given timezone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the details about this.