Skip to content

Commit d5e7cc1

Browse files
amitkduttafacebook-github-bot
authored andcommitted
misc: Throw user error for reduce function limitation (facebookincubator#12650)
Summary: Pull Request resolved: facebookincubator#12650 Reviewed By: Yuhta Differential Revision: D71208389
1 parent ce890ec commit d5e7cc1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

velox/functions/prestosql/Reduce.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ void checkArraySizes(
3838
}
3939
const auto size = rawSizes[indices[row]];
4040
// We do not want this error to be suppressed by TRY(), so we simply throw.
41-
VELOX_CHECK_LT(
42-
size,
43-
maxArraySize,
44-
"reduce lambda function doesn't support arrays with more than {} elements",
45-
maxArraySize);
41+
if (size >= maxArraySize) {
42+
VELOX_UNSUPPORTED(
43+
"Reduce lambda function doesn't support arrays with more than {} elements",
44+
maxArraySize);
45+
}
4646
});
4747
}
4848

velox/functions/prestosql/tests/ReduceTest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,9 @@ TEST_F(ReduceTest, limit) {
273273
auto data = makeRowVector({makeArrayVector(
274274
{0, 1'000, 10'000, 120'000, 120'010}, makeConstant(123, 1'000'000))});
275275

276-
VELOX_ASSERT_THROW(
276+
VELOX_ASSERT_UNSUPPORTED_THROW(
277277
evaluate("reduce(c0, 0, (s, x) -> s + x, s -> 1 * s)", data),
278-
"reduce lambda function doesn't support arrays with more than");
278+
"Reduce lambda function doesn't support arrays with more than 100000 elements");
279279

280280
// Exclude huge arrays (at rows 2 and 4).
281281
SelectivityVector rows(4);
@@ -288,9 +288,9 @@ TEST_F(ReduceTest, limit) {
288288
assertEqualVectors(expected, result, rows);
289289

290290
// TRY should not mask errors.
291-
VELOX_ASSERT_THROW(
291+
VELOX_ASSERT_UNSUPPORTED_THROW(
292292
evaluate("TRY(reduce(c0, 0, (s, x) -> s + x, s -> 1 * s))", data),
293-
"reduce lambda function doesn't support arrays with more than");
293+
"Reduce lambda function doesn't support arrays with more than 100000 elements");
294294
}
295295

296296
TEST_F(ReduceTest, rewrites) {

0 commit comments

Comments
 (0)