Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Feb 28, 2024
1 parent 53d2757 commit 370e031
Showing 1 changed file with 65 additions and 5 deletions.
70 changes: 65 additions & 5 deletions velox/functions/prestosql/window/tests/AggregateWindowTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,73 @@ TEST_F(AggregateWindowTest, testDecimal) {
TEST_F(AggregateWindowTest, integerOverflowRowsFrame) {
auto c0 = makeFlatVector<int64_t>({-1, -1, -1, -1, -1, -1, 2, 2, 2, 2});
auto c1 = makeFlatVector<double>({-1, -2, -3, -4, -5, -6, -7, -8, -9, -10});
auto input = makeRowVector({c0, c1});
// INT32_MAX: 2147483647
auto c2 = makeFlatVector<int32_t>(
{1,
2147483647,
2147483646,
2147483645,
1,
10,
1,
2147483647,
2147483646,
2147483645});
auto c3 = makeFlatVector<int64_t>(
{2147483651,
2147483650,
2147483649,
2147483648,
2147483647,
21474836,
2147483650,
2147483650,
2147483649,
2147483648});
auto input = makeRowVector({c0, c1, c2, c3});

auto expected = makeRowVector(
{c0, c1, makeFlatVector<int64_t>({6, 5, 4, 3, 2, 1, 4, 3, 2, 1})});
std::string overClause = "partition by c0 order by c1 desc";
// Use max value of int32_t.
std::string frameClause = "rows between 0 preceding and 2147483647 following";
// Test with literal larger than INT32_MAX (2147483647).
std::string frameClause = "rows between 0 preceding and 2147483650 following";
auto expected = makeRowVector(
{c0,
c1,
c2,
c3,
makeFlatVector<int64_t>({6, 5, 4, 3, 2, 1, 4, 3, 2, 1})});
WindowTestBase::testWindowFunction(
{input}, "count(c1)", overClause, frameClause, expected);

// Test integer overflow with column-specified following (int32).
frameClause = "rows between 0 preceding and c2 following";
expected = makeRowVector(
{c0,
c1,
c2,
c3,
makeFlatVector<int64_t>({2, 5, 4, 3, 2, 1, 2, 3, 2, 1})});
WindowTestBase::testWindowFunction(
{input}, "count(c1)", overClause, frameClause, expected);

// Test integer overflow with column-specified following (int64).
frameClause = "rows between 0 preceding and c3 following";
expected = makeRowVector(
{c0,
c1,
c2,
c3,
makeFlatVector<int64_t>({6, 5, 4, 3, 2, 1, 4, 3, 2, 1})});
WindowTestBase::testWindowFunction(
{input}, "count(c1)", overClause, frameClause, expected);

// Test integer overflow with column-specified preceding (int64).
frameClause = "rows between c3 preceding and 0 following";
expected = makeRowVector(
{c0,
c1,
c2,
c3,
makeFlatVector<int64_t>({1, 2, 3, 4, 5, 6, 1, 2, 3, 4})});
WindowTestBase::testWindowFunction(
{input}, "count(c1)", overClause, frameClause, expected);
}
Expand Down

0 comments on commit 370e031

Please sign in to comment.