use of org.apache.drill.exec.record.BatchSchema in project drill by apache.
the class TestBatchValidator method testVariableCorruptMiddleLow.
@Test
public void testVariableCorruptMiddleLow() {
BatchSchema schema = new SchemaBuilder().add("a", MinorType.VARCHAR).build();
SingleRowSet batch = fixture.rowSetBuilder(schema).add("xx").add("yy").add("zz").build();
zapOffset(batch, 2, 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("Decreasing offsets"));
batch.clear();
}
use of org.apache.drill.exec.record.BatchSchema in project drill by apache.
the class TestBatchValidator method testRepeatedBadArrayOffset.
@Test
public void testRepeatedBadArrayOffset() {
BatchSchema schema = new SchemaBuilder().add("a", MinorType.VARCHAR, DataMode.REPEATED).build();
SingleRowSet batch = fixture.rowSetBuilder(schema).add((Object) new String[] {}).add((Object) new String[] { "fred", "barney", "wilma" }).add((Object) new String[] { "dino" }).build();
VectorAccessible va = batch.vectorAccessible();
@SuppressWarnings("resource") ValueVector v = va.iterator().next().getValueVector();
RepeatedVarCharVector vc = (RepeatedVarCharVector) v;
@SuppressWarnings("resource") UInt4Vector ov = vc.getOffsetVector();
ov.getMutator().set(3, 1);
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.record.BatchSchema in project drill by apache.
the class TestMiniPlan method testUnionFilterAll.
@Test
@Ignore("DRILL-5327: A bug in UnionAll handling empty inputs from both sides")
public void testUnionFilterAll() throws Exception {
List<String> leftJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]");
List<String> rightJsonBatches = Lists.newArrayList("[{\"a\": 50, \"b\" : 10 }]");
RecordBatch leftScan = new JsonScanBuilder().jsonBatches(leftJsonBatches).columnsToRead("a", "b").build();
RecordBatch leftFilter = new PopBuilder().physicalOperator(new Filter(null, parseExpr("a < 0"), 1.0f)).addInput(leftScan).build();
RecordBatch rightScan = new JsonScanBuilder().jsonBatches(rightJsonBatches).columnsToRead("a", "b").build();
RecordBatch rightFilter = new PopBuilder().physicalOperator(new Filter(null, parseExpr("a < 0"), 1.0f)).addInput(rightScan).build();
RecordBatch batch = new PopBuilder().physicalOperator(// Children list is provided through RecordBatch
new UnionAll(Collections.EMPTY_LIST)).addInput(leftFilter).addInput(rightFilter).build();
BatchSchema expectedSchema = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
new MiniPlanTestBuilder().root(batch).expectedSchema(expectedSchema).go();
}
use of org.apache.drill.exec.record.BatchSchema in project drill by apache.
the class TestMiniPlan method testSimpleJson.
@Test
public void testSimpleJson() throws Exception {
List<String> jsonBatches = Lists.newArrayList("{\"a\":100}");
RecordBatch scanBatch = new JsonScanBuilder().jsonBatches(jsonBatches).build();
BatchSchema expectedSchema = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).build();
new MiniPlanTestBuilder().root(scanBatch).expectedSchema(expectedSchema).baselineValues(100L).go();
}
use of org.apache.drill.exec.record.BatchSchema in project drill by apache.
the class TestBatchValidator method testValidVariable.
@Test
public void testValidVariable() {
BatchSchema schema = new SchemaBuilder().add("a", MinorType.VARCHAR).addNullable("b", MinorType.VARCHAR).build();
SingleRowSet batch = fixture.rowSetBuilder(schema).add("col1.1", "col1.2").add("col2.1", "col2.2").add("col3.1", null).add("col4.1", "col4.2").build();
BatchValidator validator = new BatchValidator(batch.vectorAccessible(), true);
validator.validate();
assertTrue(validator.errors().isEmpty());
batch.clear();
}
Aggregations