use of org.apache.drill.exec.physical.impl.scan.file.FileMetadata in project drill by apache.
the class TestConstantColumnLoader method testFileMetadata.
@Test
public void testFileMetadata() {
FileMetadata fileInfo = new FileMetadata(new Path("hdfs:///w/x/y/z.csv"), new Path("hdfs:///w"));
List<ConstantColumnSpec> defns = new ArrayList<>();
FileMetadataColumnDefn iDefn = new FileMetadataColumnDefn(ScanTestUtils.SUFFIX_COL, ImplicitFileColumns.SUFFIX);
FileMetadataColumn iCol = new FileMetadataColumn(ScanTestUtils.SUFFIX_COL, iDefn, fileInfo, null, 0);
defns.add(iCol);
String partColName = ScanTestUtils.partitionColName(1);
PartitionColumn pCol = new PartitionColumn(partColName, 1, fileInfo, null, 0);
defns.add(pCol);
ResultVectorCacheImpl cache = new ResultVectorCacheImpl(fixture.allocator());
ConstantColumnLoader staticLoader = new ConstantColumnLoader(cache, defns);
// Create a batch
staticLoader.load(2);
// Verify
TupleMetadata expectedSchema = new SchemaBuilder().add(ScanTestUtils.SUFFIX_COL, MinorType.VARCHAR).addNullable(partColName, MinorType.VARCHAR).buildSchema();
SingleRowSet expected = fixture.rowSetBuilder(expectedSchema).addRow("csv", "y").addRow("csv", "y").build();
new RowSetComparison(expected).verifyAndClearAll(fixture.wrap(staticLoader.load(2)));
staticLoader.close();
}
Aggregations