Search in sources :

Example 1 with ImplicitInternalFileColumns

use of org.apache.drill.exec.store.ColumnExplorer.ImplicitInternalFileColumns in project drill by apache.

the class ReaderSchemaOrchestrator method projectMetadata.

/**
 * Sets {@code PROJECT_METADATA} implicit column value.
 *
 * @param projectMetadata whether {@code PROJECT_METADATA} should be replaced
 * @return {@code true} if {@code PROJECT_METADATA} implicit column
 * is present in scan projection and its value is updated
 */
private boolean projectMetadata(boolean projectMetadata) {
    ImplicitInternalFileColumns original;
    ImplicitInternalFileColumns newColumn;
    if (projectMetadata) {
        original = ImplicitInternalFileColumns.USE_METADATA;
        newColumn = ImplicitInternalFileColumns.PROJECT_METADATA;
    } else {
        original = ImplicitInternalFileColumns.PROJECT_METADATA;
        newColumn = ImplicitInternalFileColumns.USE_METADATA;
    }
    List<ColumnProjection> outputColumns = scanOrchestrator.scanProj.columns();
    for (int i = 0; i < outputColumns.size(); i++) {
        ColumnProjection outputColumn = outputColumns.get(i);
        if (outputColumn instanceof FileMetadataColumn) {
            FileMetadataColumn metadataColumn = (FileMetadataColumn) outputColumn;
            if (metadataColumn.defn().defn == original) {
                projectMetadata = scanOrchestrator.scanProj.requestedCols().stream().anyMatch(SchemaPath.getSimplePath(metadataColumn.name())::equals);
                if (projectMetadata) {
                    outputColumns.set(i, new FileMetadataColumn(metadataColumn.name(), new FileMetadataColumnDefn(metadataColumn.defn().colName(), newColumn)));
                }
                return projectMetadata;
            }
        }
    }
    return false;
}
Also used : FileMetadataColumnDefn(org.apache.drill.exec.physical.impl.scan.file.FileMetadataColumnDefn) ImplicitInternalFileColumns(org.apache.drill.exec.store.ColumnExplorer.ImplicitInternalFileColumns) FileMetadataColumn(org.apache.drill.exec.physical.impl.scan.file.FileMetadataColumn)

Aggregations

FileMetadataColumn (org.apache.drill.exec.physical.impl.scan.file.FileMetadataColumn)1 FileMetadataColumnDefn (org.apache.drill.exec.physical.impl.scan.file.FileMetadataColumnDefn)1 ImplicitInternalFileColumns (org.apache.drill.exec.store.ColumnExplorer.ImplicitInternalFileColumns)1