Search in sources :

Example 16 with SchemaBuilder

use of org.apache.drill.test.rowSet.SchemaBuilder in project drill by apache.

the class TestMiniPlan method testUnionFilter.

@Test
public void testUnionFilter() throws Exception {
    List<String> leftJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]", "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]", "[{\"a\": 40, \"b\" : 3},{\"a\": 13, \"b\" : 100}]");
    List<String> rightJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 10 }]", "[{\"a\": 50, \"b\" : 100}]");
    RecordBatch batch = new PopBuilder().physicalOperator(// Children list is provided through RecordBatch
    new UnionAll(Collections.EMPTY_LIST)).addInputAsChild().physicalOperator(new Filter(null, parseExpr("a=5"), 1.0f)).addJsonScanAsChild().jsonBatches(leftJsonBatches).columnsToRead("a", "b").buildAddAsInput().buildAddAsInput().addInputAsChild().physicalOperator(new Filter(null, parseExpr("a=50"), 1.0f)).addJsonScanAsChild().jsonBatches(rightJsonBatches).columnsToRead("a", "b").buildAddAsInput().buildAddAsInput().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).baselineValues(5l, 1l).baselineValues(5l, 5l).baselineValues(50l, 100l).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) Test(org.junit.Test)

Example 17 with SchemaBuilder

use of org.apache.drill.test.rowSet.SchemaBuilder in project drill by apache.

the class TestMiniPlan method testSimpleParquetScan.

@Test
public void testSimpleParquetScan() throws Exception {
    String file = FileUtils.getResourceAsFile("/tpchmulti/region/01.parquet").toURI().toString();
    RecordBatch scanBatch = new ParquetScanBuilder().fileSystem(fs).columnsToRead("R_REGIONKEY").inputPaths(Lists.newArrayList(file)).build();
    BatchSchema expectedSchema = new SchemaBuilder().add("R_REGIONKEY", TypeProtos.MinorType.BIGINT).build();
    new MiniPlanTestBuilder().root(scanBatch).expectedSchema(expectedSchema).baselineValues(0L).baselineValues(1L).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 18 with SchemaBuilder

use of org.apache.drill.test.rowSet.SchemaBuilder 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();
}
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 19 with SchemaBuilder

use of org.apache.drill.test.rowSet.SchemaBuilder 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();
}
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 20 with SchemaBuilder

use of org.apache.drill.test.rowSet.SchemaBuilder in project drill by apache.

the class RowSetTest method testTinyIntRW.

private void testTinyIntRW() {
    BatchSchema batchSchema = new SchemaBuilder().add("col", MinorType.TINYINT).build();
    SingleRowSet rs = fixture.rowSetBuilder(batchSchema).add(0).add(Byte.MAX_VALUE).add(Byte.MIN_VALUE).build();
    RowSetReader reader = rs.reader();
    assertTrue(reader.next());
    assertEquals(0, reader.column(0).getInt());
    assertTrue(reader.next());
    assertEquals(Byte.MAX_VALUE, reader.column(0).getInt());
    assertTrue(reader.next());
    assertEquals(Byte.MIN_VALUE, reader.column(0).getInt());
    assertFalse(reader.next());
    rs.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) RowSetReader(org.apache.drill.test.rowSet.RowSet.RowSetReader)

Aggregations

BatchSchema (org.apache.drill.exec.record.BatchSchema)26 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 RecordBatch (org.apache.drill.exec.record.RecordBatch)4 VectorAccessible (org.apache.drill.exec.record.VectorAccessible)3 RepeatedVarCharVector (org.apache.drill.exec.vector.RepeatedVarCharVector)3 UInt4Vector (org.apache.drill.exec.vector.UInt4Vector)3 ValueVector (org.apache.drill.exec.vector.ValueVector)3 RowSetComparison (org.apache.drill.test.rowSet.RowSetComparison)3 Filter (org.apache.drill.exec.physical.config.Filter)2 UnionAll (org.apache.drill.exec.physical.config.UnionAll)2 VarCharVector (org.apache.drill.exec.vector.VarCharVector)2 ClusterTest (org.apache.drill.test.ClusterTest)2 RowSet (org.apache.drill.test.rowSet.RowSet)2 RowSetBuilder (org.apache.drill.test.rowSet.RowSetBuilder)2 RowSetSchema (org.apache.drill.test.rowSet.RowSetSchema)2 PhysicalSchema (org.apache.drill.test.rowSet.RowSetSchema.PhysicalSchema)2