Search in sources :

Example 6 with BatchSchema

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();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.SchemaBuilder) BatchValidator(org.apache.drill.exec.physical.impl.validate.BatchValidator) Test(org.junit.Test)

Example 7 with BatchSchema

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();
}
Also used : ValueVector(org.apache.drill.exec.vector.ValueVector) SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) VectorAccessible(org.apache.drill.exec.record.VectorAccessible) RepeatedVarCharVector(org.apache.drill.exec.vector.RepeatedVarCharVector) BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.SchemaBuilder) BatchValidator(org.apache.drill.exec.physical.impl.validate.BatchValidator) UInt4Vector(org.apache.drill.exec.vector.UInt4Vector) Test(org.junit.Test)

Example 8 with BatchSchema

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();
}
Also used : Filter(org.apache.drill.exec.physical.config.Filter) BatchSchema(org.apache.drill.exec.record.BatchSchema) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.SchemaBuilder) UnionAll(org.apache.drill.exec.physical.config.UnionAll) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with BatchSchema

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();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.SchemaBuilder) Test(org.junit.Test)

Example 10 with BatchSchema

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();
}
Also used : SingleRowSet(org.apache.drill.test.rowSet.RowSet.SingleRowSet) BatchSchema(org.apache.drill.exec.record.BatchSchema) SchemaBuilder(org.apache.drill.test.rowSet.SchemaBuilder) BatchValidator(org.apache.drill.exec.physical.impl.validate.BatchValidator) Test(org.junit.Test)

Aggregations

BatchSchema (org.apache.drill.exec.record.BatchSchema)39 SchemaBuilder (org.apache.drill.test.rowSet.SchemaBuilder)26 Test (org.junit.Test)20 SingleRowSet (org.apache.drill.test.rowSet.RowSet.SingleRowSet)18 BatchValidator (org.apache.drill.exec.physical.impl.validate.BatchValidator)10 RowSetReader (org.apache.drill.test.rowSet.RowSet.RowSetReader)8 MaterializedField (org.apache.drill.exec.record.MaterializedField)7 ValueVector (org.apache.drill.exec.vector.ValueVector)6 SchemaChangeException (org.apache.drill.exec.exception.SchemaChangeException)4 RecordBatch (org.apache.drill.exec.record.RecordBatch)4 VectorAccessible (org.apache.drill.exec.record.VectorAccessible)4 VectorContainer (org.apache.drill.exec.record.VectorContainer)4 ArrayList (java.util.ArrayList)3 SelectionVector4 (org.apache.drill.exec.record.selection.SelectionVector4)3 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)3 DrillBuf (io.netty.buffer.DrillBuf)2 IOException (java.io.IOException)2 UserException (org.apache.drill.common.exceptions.UserException)2 MajorType (org.apache.drill.common.types.TypeProtos.MajorType)2 MinorFragmentEndpoint (org.apache.drill.exec.physical.MinorFragmentEndpoint)2