use of org.apache.drill.exec.physical.impl.validate.BatchValidator in project drill by apache.
the class TestBatchValidator method testVariableCorruptMiddleHigh.
@Test
public void testVariableCorruptMiddleHigh() {
BatchSchema schema = new SchemaBuilder().add("a", MinorType.VARCHAR).build();
SingleRowSet batch = fixture.rowSetBuilder(schema).add("xx").add("yy").add("zz").build();
zapOffset(batch, 1, 10);
// Validator should catch the error.
BatchValidator validator = new BatchValidator(batch.vectorAccessible(), true);
validator.validate();
List<String> errors = validator.errors();
assertEquals(1, errors.size());
assertTrue(errors.get(0).contains("Decreasing offsets"));
batch.clear();
}
use of org.apache.drill.exec.physical.impl.validate.BatchValidator in project drill by apache.
the class TestBatchValidator method testValidRepeated.
@Test
public void testValidRepeated() {
BatchSchema schema = new SchemaBuilder().add("a", MinorType.INT, DataMode.REPEATED).add("b", MinorType.VARCHAR, DataMode.REPEATED).build();
SingleRowSet batch = fixture.rowSetBuilder(schema).add(new int[] {}, new String[] {}).add(new int[] { 1, 2, 3 }, new String[] { "fred", "barney", "wilma" }).add(new int[] { 4 }, new String[] { "dino" }).build();
BatchValidator validator = new BatchValidator(batch.vectorAccessible(), true);
validator.validate();
assertTrue(validator.errors().isEmpty());
batch.clear();
}
use of org.apache.drill.exec.physical.impl.validate.BatchValidator in project drill by apache.
the class TestBatchValidator method testValidFixed.
@Test
public void testValidFixed() {
BatchSchema schema = new SchemaBuilder().add("a", MinorType.INT).addNullable("b", MinorType.INT).build();
SingleRowSet batch = fixture.rowSetBuilder(schema).add(10, 100).add(20, 120).add(30, null).add(40, 140).build();
BatchValidator validator = new BatchValidator(batch.vectorAccessible(), true);
validator.validate();
assertTrue(validator.errors().isEmpty());
batch.clear();
}
use of org.apache.drill.exec.physical.impl.validate.BatchValidator in project drill by apache.
the class TestBatchValidator method testVariableCorruptFirst.
@Test
public void testVariableCorruptFirst() {
BatchSchema schema = new SchemaBuilder().add("a", MinorType.VARCHAR).build();
SingleRowSet batch = fixture.rowSetBuilder(schema).add("x").add("y").add("z").build();
zapOffset(batch, 0, 1);
// Validator should catch the error.
BatchValidator validator = new BatchValidator(batch.vectorAccessible(), true);
validator.validate();
List<String> errors = validator.errors();
assertEquals(1, errors.size());
assertTrue(errors.get(0).contains("Offset (0) must be 0"));
batch.clear();
}
use of org.apache.drill.exec.physical.impl.validate.BatchValidator in project drill by apache.
the class TestBatchValidator method testVariableMissingLast.
@Test
public void testVariableMissingLast() {
BatchSchema schema = new SchemaBuilder().add("a", MinorType.VARCHAR).build();
SingleRowSet batch = fixture.rowSetBuilder(schema).add("x").add("y").add("z").build();
// Here we are evil: stomp on the last offset to simulate corruption.
// Don't do this in real code!
VectorAccessible va = batch.vectorAccessible();
@SuppressWarnings("resource") ValueVector v = va.iterator().next().getValueVector();
VarCharVector vc = (VarCharVector) v;
@SuppressWarnings("resource") UInt4Vector ov = vc.getOffsetVector();
assertTrue(ov.getAccessor().get(3) > 0);
ov.getMutator().set(3, 0);
// Validator should catch the error.
BatchValidator validator = new BatchValidator(batch.vectorAccessible(), true);
validator.validate();
List<String> errors = validator.errors();
assertEquals(1, errors.size());
assertTrue(errors.get(0).contains("Decreasing offsets"));
batch.clear();
}
Aggregations