use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestLoad method testLoadValueVector.
@Test
public void testLoadValueVector() throws Exception {
final BufferAllocator allocator = RootAllocatorFactory.newRoot(drillConfig);
SchemaBuilder schemaBuilder = new SchemaBuilder().add("ints", MinorType.INT).add("chars", MinorType.VARCHAR).addNullable("chars2", MinorType.VARCHAR);
BatchSchema schema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
// Create vectors
final List<ValueVector> vectors = createVectors(allocator, schema, 100);
// Writeable batch now owns vector buffers
final WritableBatch writableBatch = WritableBatch.getBatchNoHV(100, vectors, false);
// Serialize the vectors
final DrillBuf byteBuf = serializeBatch(allocator, writableBatch);
// Batch loader does NOT take ownership of the serialized buffer
final RecordBatchLoader batchLoader = new RecordBatchLoader(allocator);
batchLoader.load(writableBatch.getDef(), byteBuf);
// Release the serialized buffer.
byteBuf.release();
// TODO: Do actual validation
assertEquals(100, batchLoader.getRecordCount());
// Free the original vectors
writableBatch.clear();
// Free the deserialized vectors
batchLoader.clear();
// The allocator will verify that the frees were done correctly.
allocator.close();
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestMiniPlan method testSimpleParquetScan.
@Test
public void testSimpleParquetScan() throws Exception {
String file = DrillFileUtils.getResourceAsFile("/tpchmulti/region/01.parquet").toURI().toString();
List<Path> filePath = Collections.singletonList(new Path(file));
RecordBatch scanBatch = new ParquetScanBuilder().fileSystem(fs).columnsToRead("R_REGIONKEY").inputPaths(filePath).build();
SchemaBuilder schemaBuilder = new SchemaBuilder().add("R_REGIONKEY", TypeProtos.MinorType.BIGINT);
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
new MiniPlanTestBuilder().root(scanBatch).expectSchema(expectedSchema).baselineValues(0L).baselineValues(1L).go();
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestNullInputMiniPlan method testLeftHashJoinLeftEmpty.
@Test
public void testLeftHashJoinLeftEmpty() throws Exception {
RecordBatch left = createScanBatchFromJson(SINGLE_EMPTY_JSON);
List<String> rightJsonBatches = Lists.newArrayList("[{\"a\": 50, \"b\" : 10 }]");
RecordBatch rightScan = new JsonScanBuilder().jsonBatches(rightJsonBatches).columnsToRead("a", "b").build();
RecordBatch joinBatch = new PopBuilder().physicalOperator(new HashJoinPOP(null, null, Lists.newArrayList(joinCond("a2", "EQUALS", "a")), JoinRelType.LEFT, null)).addInput(left).addInput(rightScan).build();
SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT);
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
new MiniPlanTestBuilder().root(joinBatch).expectSchema(expectedSchema).expectZeroRow(true).go();
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestNullInputMiniPlan method testLeftHashJoinRightEmpty.
@Test
public void testLeftHashJoinRightEmpty() throws Exception {
List<String> leftJsonBatches = Lists.newArrayList("[{\"a\": 50, \"b\" : 10 }]");
RecordBatch leftScan = new JsonScanBuilder().jsonBatches(leftJsonBatches).columnsToRead("a", "b").build();
RecordBatch right = createScanBatchFromJson(SINGLE_EMPTY_JSON);
RecordBatch joinBatch = new PopBuilder().physicalOperator(new HashJoinPOP(null, null, Lists.newArrayList(joinCond("a", "EQUALS", "a2")), JoinRelType.LEFT, null)).addInput(leftScan).addInput(right).build();
SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT);
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
new MiniPlanTestBuilder().root(joinBatch).expectSchema(expectedSchema).baselineValues(50L, 10L).go();
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestNullInputMiniPlan method testHashJoinRightEmpty.
@Test
public void testHashJoinRightEmpty() throws Exception {
List<String> leftJsonBatches = Lists.newArrayList("[{\"a\": 50, \"b\" : 10 }]");
RecordBatch leftScan = new JsonScanBuilder().jsonBatches(leftJsonBatches).columnsToRead("a", "b").build();
RecordBatch right = createScanBatchFromJson(SINGLE_EMPTY_JSON);
RecordBatch joinBatch = new PopBuilder().physicalOperator(new HashJoinPOP(null, null, Lists.newArrayList(joinCond("a", "EQUALS", "a2")), JoinRelType.INNER, null)).addInput(leftScan).addInput(right).build();
SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT);
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
new MiniPlanTestBuilder().root(joinBatch).expectSchema(expectedSchema).expectZeroRow(true).go();
}
Aggregations