use of org.apache.calcite.adapter.enumerable.EnumerableTableScan in project drill by apache.
the class FileSystemPartitionDescriptor method createTableScan.
@Override
public TableScan createTableScan(List<PartitionLocation> newPartitionLocation, String cacheFileRoot, boolean wasAllPartitionsPruned, MetadataContext metaContext) throws Exception {
List<String> newFiles = Lists.newArrayList();
for (final PartitionLocation location : newPartitionLocation) {
if (!location.isCompositePartition()) {
newFiles.add(location.getEntirePartitionLocation());
} else {
final Collection<SimplePartitionLocation> subPartitions = location.getPartitionLocationRecursive();
for (final PartitionLocation subPart : subPartitions) {
newFiles.add(subPart.getEntirePartitionLocation());
}
}
}
if (scanRel instanceof DrillScanRel) {
final FormatSelection formatSelection = (FormatSelection) table.getSelection();
final FileSelection newFileSelection = new FileSelection(null, newFiles, getBaseTableLocation(), cacheFileRoot, wasAllPartitionsPruned, formatSelection.getSelection().getDirStatus());
newFileSelection.setMetaContext(metaContext);
final FileGroupScan newGroupScan = ((FileGroupScan) ((DrillScanRel) scanRel).getGroupScan()).clone(newFileSelection);
return new DrillScanRel(scanRel.getCluster(), scanRel.getTraitSet().plus(DrillRel.DRILL_LOGICAL), scanRel.getTable(), newGroupScan, scanRel.getRowType(), ((DrillScanRel) scanRel).getColumns(), true);
} else if (scanRel instanceof EnumerableTableScan) {
return createNewTableScanFromSelection((EnumerableTableScan) scanRel, newFiles, cacheFileRoot, wasAllPartitionsPruned, metaContext);
} else {
throw new UnsupportedOperationException("Only DrillScanRel and EnumerableTableScan is allowed!");
}
}
use of org.apache.calcite.adapter.enumerable.EnumerableTableScan in project drill by apache.
the class DrillScanRule method onMatch.
@Override
public void onMatch(RelOptRuleCall call) {
final EnumerableTableScan access = (EnumerableTableScan) call.rel(0);
final RelTraitSet traits = access.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
call.transformTo(new DrillScanRel(access.getCluster(), traits, access.getTable()));
}
use of org.apache.calcite.adapter.enumerable.EnumerableTableScan in project drill by apache.
the class FileSystemPartitionDescriptor method getFileLocationsAndStatus.
protected Pair<Collection<String>, Boolean> getFileLocationsAndStatus() {
Collection<String> fileLocations = null;
Pair<Collection<String>, Boolean> fileLocationsAndStatus = null;
boolean isExpandedPartial = false;
if (scanRel instanceof DrillScanRel) {
// If a particular GroupScan provides files, get the list of files from there rather than
// DrillTable because GroupScan would have the updated version of the selection
final DrillScanRel drillScan = (DrillScanRel) scanRel;
if (drillScan.getGroupScan().hasFiles()) {
fileLocations = drillScan.getGroupScan().getFiles();
isExpandedPartial = false;
} else {
FileSelection selection = ((FormatSelection) table.getSelection()).getSelection();
fileLocations = selection.getFiles();
isExpandedPartial = selection.isExpandedPartial();
}
} else if (scanRel instanceof EnumerableTableScan) {
FileSelection selection = ((FormatSelection) table.getSelection()).getSelection();
fileLocations = selection.getFiles();
isExpandedPartial = selection.isExpandedPartial();
}
fileLocationsAndStatus = Pair.of(fileLocations, isExpandedPartial);
return fileLocationsAndStatus;
}
Aggregations