Skip to content

Commit 802f338

Browse files
committed
Make sure that Arguments and Examples have a correct format
1 parent 9b9bfca commit 802f338

File tree

3 files changed

+27
-26
lines changed

3 files changed

+27
-26
lines changed

sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/ExpressionInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,9 @@ public ExpressionInfo(
105105
String deprecated) {
106106
assert name != null;
107107
assert arguments != null;
108+
assert arguments.isEmpty() || arguments.startsWith("\n Arguments:\n");
108109
assert examples != null;
109-
assert examples.isEmpty() || examples.contains(" Examples:");
110+
assert examples.isEmpty() || examples.startsWith("\n Examples:\n");
110111
assert note != null;
111112
assert group != null;
112113
assert since != null;

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,13 +1565,13 @@ trait TruncInstant extends BinaryExpression with ImplicitCastInputTypes {
15651565
_FUNC_(date, fmt) - Returns `date` with the time portion of the day truncated to the unit specified by the format model `fmt`.
15661566
""",
15671567
arguments = """
1568-
Arguments:
1569-
* date - date value or valid date string
1570-
* fmt - the format representing the unit to be truncated to
1571-
- "YEAR", "YYYY", "YY" - truncate to the first date of the year that the `date` falls in
1572-
- "QUARTER" - truncate to the first date of the quarter that the `date` falls in
1573-
- "MONTH", "MM", "MON" - truncate to the first date of the month that the `date` falls in
1574-
- "WEEK" - truncate to the Monday of the week that the `date` falls in
1568+
Arguments:
1569+
* date - date value or valid date string
1570+
* fmt - the format representing the unit to be truncated to
1571+
- "YEAR", "YYYY", "YY" - truncate to the first date of the year that the `date` falls in
1572+
- "QUARTER" - truncate to the first date of the quarter that the `date` falls in
1573+
- "MONTH", "MM", "MON" - truncate to the first date of the month that the `date` falls in
1574+
- "WEEK" - truncate to the Monday of the week that the `date` falls in
15751575
""",
15761576
examples = """
15771577
Examples:
@@ -1619,19 +1619,19 @@ case class TruncDate(date: Expression, format: Expression)
16191619
_FUNC_(fmt, ts) - Returns timestamp `ts` truncated to the unit specified by the format model `fmt`.
16201620
""",
16211621
arguments = """
1622-
Arguments:
1623-
* fmt - the format representing the unit to be truncated to
1624-
- "YEAR", "YYYY", "YY" - truncate to the first date of the year that the `ts` falls in, the time part will be zero out
1625-
- "QUARTER" - truncate to the first date of the quarter that the `ts` falls in, the time part will be zero out
1626-
- "MONTH", "MM", "MON" - truncate to the first date of the month that the `ts` falls in, the time part will be zero out
1627-
- "WEEK" - truncate to the Monday of the week that the `ts` falls in, the time part will be zero out
1628-
- "DAY", "DD" - zero out the time part
1629-
- "HOUR" - zero out the minute and second with fraction part
1630-
- "MINUTE"- zero out the second with fraction part
1631-
- "SECOND" - zero out the second fraction part
1632-
- "MILLISECOND" - zero out the microseconds
1633-
- "MICROSECOND" - everything remains
1634-
* ts - datetime value or valid timestamp string
1622+
Arguments:
1623+
* fmt - the format representing the unit to be truncated to
1624+
- "YEAR", "YYYY", "YY" - truncate to the first date of the year that the `ts` falls in, the time part will be zero out
1625+
- "QUARTER" - truncate to the first date of the quarter that the `ts` falls in, the time part will be zero out
1626+
- "MONTH", "MM", "MON" - truncate to the first date of the month that the `ts` falls in, the time part will be zero out
1627+
- "WEEK" - truncate to the Monday of the week that the `ts` falls in, the time part will be zero out
1628+
- "DAY", "DD" - zero out the time part
1629+
- "HOUR" - zero out the minute and second with fraction part
1630+
- "MINUTE"- zero out the second with fraction part
1631+
- "SECOND" - zero out the second fraction part
1632+
- "MILLISECOND" - zero out the microseconds
1633+
- "MICROSECOND" - everything remains
1634+
* ts - datetime value or valid timestamp string
16351635
""",
16361636
examples = """
16371637
Examples:

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ case class SparkVersion() extends LeafExpression with CodegenFallback {
208208
@ExpressionDescription(
209209
usage = """_FUNC_(expr) - Return DDL-formatted type string for the data type of the input.""",
210210
examples = """
211-
Examples:
212-
> SELECT _FUNC_(1);
213-
int
214-
> SELECT _FUNC_(array(1));
215-
array<int>
211+
Examples:
212+
> SELECT _FUNC_(1);
213+
int
214+
> SELECT _FUNC_(array(1));
215+
array<int>
216216
""",
217217
since = "3.0.0")
218218
case class TypeOf(child: Expression) extends UnaryExpression {

0 commit comments

Comments
 (0)