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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations