use of com.facebook.presto.common.InvalidFunctionArgumentException in project presto by prestodb.
the class TestSelectiveOrcReader method testArrayIndexOutOfBounds.
@Test
public void testArrayIndexOutOfBounds() throws Exception {
Random random = new Random(0);
// non-null arrays of varying sizes
try {
tester.testRoundTrip(arrayType(INTEGER), createList(NUM_ROWS, i -> randomIntegers(random.nextInt(10), random)), ImmutableList.of(ImmutableMap.of(new Subfield("c[2]"), IS_NULL)));
fail("Expected 'Array subscript out of bounds' exception");
} catch (InvalidFunctionArgumentException e) {
assertTrue(e.getMessage().contains("Array subscript out of bounds"));
}
// non-null nested arrays of varying sizes
try {
tester.testRoundTrip(arrayType(arrayType(INTEGER)), createList(NUM_ROWS, i -> ImmutableList.of(randomIntegers(random.nextInt(5), random), randomIntegers(random.nextInt(5), random))), ImmutableList.of(ImmutableMap.of(new Subfield("c[2][3]"), IS_NULL)));
fail("Expected 'Array subscript out of bounds' exception");
} catch (InvalidFunctionArgumentException e) {
assertTrue(e.getMessage().contains("Array subscript out of bounds"));
}
// empty arrays
try {
tester.testRoundTrip(arrayType(INTEGER), nCopies(NUM_ROWS, ImmutableList.of()), ImmutableList.of(ImmutableMap.of(new Subfield("c[2]"), IS_NULL)));
fail("Expected 'Array subscript out of bounds' exception");
} catch (InvalidFunctionArgumentException e) {
assertTrue(e.getMessage().contains("Array subscript out of bounds"));
}
// empty nested arrays
try {
tester.testRoundTrip(arrayType(arrayType(INTEGER)), nCopies(NUM_ROWS, ImmutableList.of()), ImmutableList.of(ImmutableMap.of(new Subfield("c[2][3]"), IS_NULL)));
fail("Expected 'Array subscript out of bounds' exception");
} catch (InvalidFunctionArgumentException e) {
assertTrue(e.getMessage().contains("Array subscript out of bounds"));
}
}
Aggregations