Skip to content

Commit

Permalink
Improve the error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
beliefer committed May 10, 2021
1 parent d808956 commit 1126b06
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2852,8 +2852,8 @@ object Sequence {
val (stepMonths, stepDays, stepMicros) = splitStep(input3)

if (scale == MICROS_PER_DAY && stepMonths == 0 && stepDays == 0) {
throw new IllegalArgumentException(
s"sequence step must be a day ${intervalType.typeName} if start and end values are dates")
throw new IllegalArgumentException(s"sequence step must be an ${intervalType.typeName}" +
" of day granularity if start and end values are dates")
}

if (stepMonths == 0 && stepMicros == 0 && scale == MICROS_PER_DAY) {
Expand Down Expand Up @@ -2929,8 +2929,8 @@ object Sequence {
s"""
|if ($stepMonths == 0 && $stepDays == 0) {
| throw new IllegalArgumentException(
| "sequence step must be a day ${intervalType.typeName} " +
| "if start and end values are dates");
| "sequence step must be an ${intervalType.typeName} " +
| "of day granularity if start and end values are dates");
|}
""".stripMargin
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ class CollectionExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper
Cast(Literal("2011-03-01"), DateType),
Cast(Literal("2011-04-01"), DateType),
Option(Literal(stringToInterval("interval 1 hour")))), null,
"sequence step must be a day interval if start and end values are dates")
"sequence step must be an interval of day granularity if start and end values are dates")
}
}

Expand Down Expand Up @@ -1098,7 +1098,8 @@ class CollectionExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper
Literal(Date.valueOf("2018-01-05")),
Literal(Period.ofDays(2))),
EmptyRow,
"sequence step must be a day interval year to month if start and end values are dates")
"sequence step must be an interval year to month of day granularity" +
" if start and end values are dates")

checkExceptionInExpression[IllegalArgumentException](
new Sequence(
Expand Down

0 comments on commit 1126b06

Please sign in to comment.