Skip to content

Commit

Permalink
Fix argument validation in sequence function
Browse files Browse the repository at this point in the history
  • Loading branch information
ngqtien authored and haozhun committed Mar 9, 2018
1 parent 8088788 commit f087816
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Expand Up @@ -157,9 +157,9 @@ private static void checkValidStep(long start, long stop, long step)
INVALID_FUNCTION_ARGUMENT,
"step must not be zero");
checkCondition(
step > 0 ? stop >= start : stop < start,
step > 0 ? stop >= start : stop <= start,
INVALID_FUNCTION_ARGUMENT,
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start");
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than or equal to start");
}

private static void checkMaxEntry(int length)
Expand Down
Expand Up @@ -1348,11 +1348,11 @@ public void testSequenceDateTimeDayToSecond()
assertInvalidFunction(
"SEQUENCE(date '2016-04-12', date '2016-04-14', interval '-1' day)",
INVALID_FUNCTION_ARGUMENT,
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start");
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than or equal to start");
assertInvalidFunction(
"SEQUENCE(date '2016-04-14', date '2016-04-12', interval '1' day)",
INVALID_FUNCTION_ARGUMENT,
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start");
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than or equal to start");
assertInvalidFunction(
"SEQUENCE(date '2000-04-14', date '2030-04-12', interval '1' day)",
INVALID_FUNCTION_ARGUMENT,
Expand All @@ -1364,11 +1364,11 @@ public void testSequenceDateTimeDayToSecond()
assertInvalidFunction(
"SEQUENCE(timestamp '2016-04-16 01:00:10', timestamp '2016-04-16 01:01:00', interval '-20' second)",
INVALID_FUNCTION_ARGUMENT,
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start");
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than or equal to start");
assertInvalidFunction(
"SEQUENCE(timestamp '2016-04-16 01:10:10', timestamp '2016-04-16 01:01:00', interval '20' second)",
INVALID_FUNCTION_ARGUMENT,
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start");
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than or equal to start");
assertInvalidFunction(
"SEQUENCE(timestamp '2016-04-16 01:00:10', timestamp '2016-04-16 09:01:00', interval '1' second)",
INVALID_FUNCTION_ARGUMENT,
Expand Down Expand Up @@ -1428,23 +1428,23 @@ public void testSequenceDateTimeYearToMonth()
assertInvalidFunction(
"SEQUENCE(date '2016-06-12', date '2016-04-12', interval '1' month)",
INVALID_FUNCTION_ARGUMENT,
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start");
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than or equal to start");
assertInvalidFunction(
"SEQUENCE(date '2016-04-12', date '2016-06-12', interval '-1' month)",
INVALID_FUNCTION_ARGUMENT,
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start");
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than or equal to start");
assertInvalidFunction(
"SEQUENCE(date '2000-04-12', date '3000-06-12', interval '1' month)",
INVALID_FUNCTION_ARGUMENT,
"result of sequence function must not have more than 10000 entries");
assertInvalidFunction(
"SEQUENCE(timestamp '2016-05-16 01:00:10', timestamp '2016-04-16 01:01:00', interval '1' month)",
INVALID_FUNCTION_ARGUMENT,
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start");
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than or equal to start");
assertInvalidFunction(
"SEQUENCE(timestamp '2016-04-16 01:10:10', timestamp '2016-05-16 01:01:00', interval '-1' month)",
INVALID_FUNCTION_ARGUMENT,
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than start");
"sequence stop value should be greater than or equal to start value if step is greater than zero otherwise stop should be less than or equal to start");
assertInvalidFunction(
"SEQUENCE(timestamp '2016-04-16 01:00:10', timestamp '3000-04-16 09:01:00', interval '1' month)",
INVALID_FUNCTION_ARGUMENT,
Expand Down

0 comments on commit f087816

Please sign in to comment.