Skip to content

Commit

Permalink
[FLINK-11279] [table] Fix week interval parsing in ExpressionParser
Browse files Browse the repository at this point in the history
This closes apache#7426.
  • Loading branch information
XuQianJin-Stars authored and twalthr committed Jan 8, 2019
1 parent 79f3170 commit 90f3b42
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ object ExpressionParser extends JavaTokenParsers with PackratParsers {

case expr ~ _ ~ (MONTHS.key | MONTH.key) => toMonthInterval(expr, 1)

case expr ~ _ ~ (WEEKS.key | WEEKS.key) => toMilliInterval(expr, 7 * MILLIS_PER_DAY)
case expr ~ _ ~ (WEEKS.key | WEEK.key) => toMilliInterval(expr, 7 * MILLIS_PER_DAY)

case expr ~ _ ~ (DAYS.key | DAY.key) => toMilliInterval(expr, MILLIS_PER_DAY)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2764,6 +2764,11 @@ class ScalarFunctionsTest extends ScalarTypesTestBase {
"'2016-03-31'.toDate - 1.month",
"timestampadd(MONTH, -1, date '2016-03-31')",
"2016-02-29")

testAllApis("2016-03-31".toDate - 1.week,
"'2016-03-31'.toDate - 1.week",
"timestampadd(WEEK, -1, date '2016-03-31')",
"2016-03-24")
}

// ----------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 90f3b42

Please sign in to comment.