use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestUnionDistinct method testUnionBothEmptyDirs.
@Test
public void testUnionBothEmptyDirs() throws Exception {
SchemaBuilder schemaBuilder = new SchemaBuilder().addNullable("key", TypeProtos.MinorType.INT);
final BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
testBuilder().sqlQuery("SELECT key FROM dfs.tmp.`%1$s` UNION SELECT key FROM dfs.tmp.`%1$s`", EMPTY_DIR_NAME).schemaBaseLine(expectedSchema).build().run();
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestUntypedNull method testCoalesceOnNotExistentColumnsWithGroupBy.
@Test
public void testCoalesceOnNotExistentColumnsWithGroupBy() throws Exception {
String query = "select coalesce(unk1, unk2) as coal from cp.`tpch/nation.parquet` group by 1";
SchemaBuilder schemaBuilder = new SchemaBuilder().add("coal", UNTYPED_NULL_TYPE);
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
testBuilder().sqlQuery(query).schemaBaseLine(expectedSchema).go();
testBuilder().sqlQuery(query).unOrdered().baselineColumns("coal").baselineValuesForSingleColumn(new Object[] { null }).go();
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestHashJoinAdvanced method testJoinLimit0Schema.
// DRILL-6606
@Test
public void testJoinLimit0Schema() throws Exception {
String query = "SELECT l.l_quantity, l.l_shipdate, o.o_custkey\n" + "FROM (SELECT * FROM cp.`tpch/lineitem.parquet` LIMIT 0) l\n" + " JOIN (SELECT * FROM cp.`tpch/orders.parquet` LIMIT 0) o \n" + " ON l.l_orderkey = o.o_orderkey\n";
final List<QueryDataBatch> dataBatches = client.runQuery(UserBitShared.QueryType.SQL, query);
Assert.assertEquals(1, dataBatches.size());
final QueryDataBatch queryDataBatch = dataBatches.get(0);
final RecordBatchLoader batchLoader = new RecordBatchLoader(getAllocator());
try {
batchLoader.load(queryDataBatch.getHeader().getDef(), queryDataBatch.getData());
final BatchSchema actualSchema = batchLoader.getSchema();
SchemaBuilder schemaBuilder = new SchemaBuilder().add("l_quantity", TypeProtos.MinorType.FLOAT8, TypeProtos.DataMode.REQUIRED).add("l_shipdate", TypeProtos.MinorType.DATE, TypeProtos.DataMode.REQUIRED).add("o_custkey", TypeProtos.MinorType.INT, TypeProtos.DataMode.REQUIRED);
final BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build();
Assert.assertTrue(expectedSchema.isEquivalent(actualSchema));
} finally {
batchLoader.clear();
}
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestOperatorRecordBatch method mockBatch.
private static VectorContainer mockBatch() {
SchemaBuilder schemaBuilder = new SchemaBuilder().add("a", MinorType.INT);
VectorContainer container = new VectorContainer(fixture.allocator(), new BatchSchemaBuilder().withSchemaBuilder(schemaBuilder).build());
container.buildSchema(SelectionVectorMode.NONE);
return container;
}
use of org.apache.drill.exec.record.BatchSchemaBuilder in project drill by apache.
the class TestFileScanFramework method testEmptyProject.
@Test
public void testEmptyProject() {
MockEarlySchemaReader reader = new MockEarlySchemaReader();
reader.batchLimit = 1;
// Select no columns
FileScanFixtureBuilder builder = new FileScanFixtureBuilder();
builder.setProjection();
builder.addReader(reader);
ScanFixture scanFixture = builder.build();
ScanOperatorExec scan = scanFixture.scanOp;
// Expect data and implicit columns
BatchSchema expectedSchema = new BatchSchemaBuilder().withSchemaBuilder(new SchemaBuilder()).build();
SingleRowSet expected = fixture.rowSetBuilder(expectedSchema).addRow().addRow().build();
// Schema should include implicit columns.
assertTrue(scan.buildSchema());
assertEquals(expectedSchema, scan.batchAccessor().schema());
scan.batchAccessor().release();
// Read one batch, should contain implicit columns
assertTrue(scan.next());
RowSetUtilities.verify(expected, fixture.wrap(scan.batchAccessor().container()));
// EOF
assertFalse(scan.next());
assertEquals(0, scan.batchAccessor().rowCount());
scanFixture.close();
}
Aggregations