use of org.apache.drill.exec.physical.base.SchemalessScan in project drill by apache.
the class FileMetadataInfoCollector method getTableScan.
private TableScan getTableScan(PlannerSettings settings, TableScan scanRel, List<String> scanFiles) {
FileSystemPartitionDescriptor descriptor = new FileSystemPartitionDescriptor(settings, scanRel);
List<PartitionLocation> newPartitions = Lists.newArrayList(descriptor.iterator()).stream().flatMap(Collection::stream).flatMap(p -> p.getPartitionLocationRecursive().stream()).filter(p -> scanFiles.contains(p.getEntirePartitionLocation().toUri().getPath())).collect(Collectors.toList());
try {
if (!newPartitions.isEmpty()) {
return descriptor.createTableScan(newPartitions, false);
} else {
DrillTable drillTable = descriptor.getTable();
SchemalessScan scan = new SchemalessScan(drillTable.getUserName(), ((FormatSelection) descriptor.getTable().getSelection()).getSelection().getSelectionRoot());
return new DrillScanRel(scanRel.getCluster(), scanRel.getTraitSet().plus(DrillRel.DRILL_LOGICAL), scanRel.getTable(), scan, scanRel.getRowType(), DrillScanRel.getProjectedColumns(scanRel.getTable(), true), true);
}
} catch (Exception e) {
throw new RuntimeException("Error happened during recreation of pruned scan", e);
}
}
Aggregations