Search in sources :

Example 1 with ScanTaskTableScanIterable

use of org.apache.iceberg.data.ScanTaskTableScanIterable in project drill by apache.

the class IcebergRecordReader method open.

@Override
public boolean open(SchemaNegotiator negotiator) {
    TupleSchema tableSchema = new TupleSchema();
    tableScan.schema().columns().stream().map(IcebergColumnConverterFactory::getColumnMetadata).forEach(tableSchema::add);
    TupleMetadata providedSchema = negotiator.providedSchema();
    TupleMetadata tupleSchema = FixedReceiver.Builder.mergeSchemas(providedSchema, tableSchema);
    negotiator.tableSchema(tupleSchema, true);
    loader = negotiator.build();
    this.taskToClose = new ScanTaskTableScanIterable(tableScan, work.getScanTask());
    this.records = taskToClose.iterator();
    ColumnConverterFactory factory = new IcebergColumnConverterFactory(providedSchema);
    converter = factory.getRootConverter(providedSchema, tableSchema, loader.writer());
    return true;
}
Also used : ScanTaskTableScanIterable(org.apache.iceberg.data.ScanTaskTableScanIterable) ColumnConverterFactory(org.apache.drill.exec.record.ColumnConverterFactory) TupleMetadata(org.apache.drill.exec.record.metadata.TupleMetadata) TupleSchema(org.apache.drill.exec.record.metadata.TupleSchema)

Aggregations

ColumnConverterFactory (org.apache.drill.exec.record.ColumnConverterFactory)1 TupleMetadata (org.apache.drill.exec.record.metadata.TupleMetadata)1 TupleSchema (org.apache.drill.exec.record.metadata.TupleSchema)1 ScanTaskTableScanIterable (org.apache.iceberg.data.ScanTaskTableScanIterable)1