use of org.apache.drill.exec.physical.rowSet.RowSet in project drill by apache.
the class TestImplicitColumnLoader method testInternalColumns.
@Test
public void testInternalColumns() {
ImplicitFixture testFixture = new ImplicitFixture(RowSetTestUtils.projectList(ScanTestUtils.LAST_MODIFIED_TIME_COL, ScanTestUtils.PROJECT_METADATA_COL, ScanTestUtils.ROW_GROUP_INDEX_COL, ScanTestUtils.ROW_GROUP_START_COL, ScanTestUtils.ROW_GROUP_LENGTH_COL), MOCK_ROOT_PATH);
testFixture.build(MOCK_FILE_PATH);
testFixture.fileDescrip.setRowGroupAttribs(10, 10_000, 5_000);
testFixture.fileDescrip.setModTime("123456789");
StaticBatchBuilder batchLoader = testFixture.batchBuilder();
assertNotNull(batchLoader);
batchLoader.load(2);
TupleMetadata expectedSchema = new SchemaBuilder().add(ScanTestUtils.LAST_MODIFIED_TIME_COL, MinorType.VARCHAR).addNullable(ScanTestUtils.PROJECT_METADATA_COL, MinorType.VARCHAR).add(ScanTestUtils.ROW_GROUP_INDEX_COL, MinorType.VARCHAR).add(ScanTestUtils.ROW_GROUP_START_COL, MinorType.VARCHAR).add(ScanTestUtils.ROW_GROUP_LENGTH_COL, MinorType.VARCHAR).build();
RowSet expected = fixture.rowSetBuilder(expectedSchema).addRow("123456789", null, "10", "10000", "5000").addRow("123456789", null, "10", "10000", "5000").build();
RowSetUtilities.verify(expected, fixture.wrap(batchLoader.outputContainer()));
}
use of org.apache.drill.exec.physical.rowSet.RowSet in project drill by apache.
the class TestOutputBatchBuilder method testReorder.
@Test
public void testReorder() {
TupleMetadata schema = firstSchema();
VectorContainer input = makeFirst(schema);
TupleMetadata outputSchema = new SchemaBuilder().add("a", MinorType.INT).add("d", MinorType.VARCHAR).buildSchema();
OutputBatchBuilder builder = new OutputBatchBuilder(outputSchema, Collections.singletonList(new BatchSource(schema, input)), fixture.allocator());
builder.load(input.getRecordCount());
VectorContainer output = builder.outputContainer();
RowSet expected = fixture.rowSetBuilder(outputSchema).addRow(10, "barney").addRow(20, "wilma").build();
RowSetUtilities.verify(expected, fixture.wrap(output));
}
use of org.apache.drill.exec.physical.rowSet.RowSet in project drill by apache.
the class TestScanLifecycleBasics method testEarlySchemaSubset.
/**
* Test SELECT a FROM table(a, b)
*/
@Test
public void testEarlySchemaSubset() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.projection(RowSetTestUtils.projectList("a"));
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.SOME, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
// Early schema: so output schema is available after open
TupleMetadata expectedSchema = new SchemaBuilder().add("a", MinorType.INT).build();
assertEquals(expectedSchema, scan.outputSchema());
assertTrue(reader.next());
RowSet expected = fixture.rowSetBuilder(expectedSchema).addRow(10).addRow(20).build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.rowSet.RowSet in project drill by apache.
the class TestScanLifecycleBasics method testEarlySchemaWithProjectNone.
@Test
public void testEarlySchemaWithProjectNone() {
ScanLifecycleBuilder builder = new ScanLifecycleBuilder();
builder.projection(RowSetTestUtils.projectNone());
builder.readerFactory(new SingleReaderFactory() {
@Override
public ManagedReader next(SchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.NONE, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
// Early schema: so output schema is available after open
TupleMetadata expectedSchema = new SchemaBuilder().build();
assertEquals(expectedSchema, scan.outputSchema());
assertTrue(reader.next());
RowSet expected = fixture.rowSetBuilder(expectedSchema).addRow().addRow().build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
use of org.apache.drill.exec.physical.rowSet.RowSet in project drill by apache.
the class TestFileScanLifecycle method testWildcard.
@Test
public void testWildcard() {
FileScanLifecycleBuilder builder = new FileScanLifecycleBuilder();
builder.rootDir(MOCK_ROOT_PATH);
builder.maxPartitionDepth(3);
builder.fileSplits(Collections.singletonList(new DummyFileWork(MOCK_FILE_PATH)));
builder.useLegacyWildcardExpansion(true);
builder.readerFactory(new FileReaderFactory() {
@Override
public ManagedReader newReader(FileSchemaNegotiator negotiator) {
return new MockEarlySchemaReader(negotiator, 1);
}
});
ScanLifecycle scan = buildScan(builder);
assertSame(ProjectionType.ALL, scan.schemaTracker().projectionType());
RowBatchReader reader = scan.nextReader();
assertTrue(reader.open());
assertTrue(reader.next());
TupleMetadata expectedSchema = new SchemaBuilder().addAll(SCHEMA).add(FileScanUtils.partitionColName(0), PARTITION_COL_TYPE).add(FileScanUtils.partitionColName(1), PARTITION_COL_TYPE).add(FileScanUtils.partitionColName(2), PARTITION_COL_TYPE).build();
RowSet expected = fixture.rowSetBuilder(expectedSchema).addRow(10, "fred", MOCK_DIR0, MOCK_DIR1, null).addRow(20, "wilma", MOCK_DIR0, MOCK_DIR1, null).build();
RowSetUtilities.verify(expected, fixture.wrap(reader.output()));
assertFalse(reader.next());
reader.close();
scan.close();
}
Aggregations