szehon-ho commented on code in PR #5376:
URL: https://github.com/apache/iceberg/pull/5376#discussion_r950416982
##########
core/src/main/java/org/apache/iceberg/BaseFilesTable.java:
##########
@@ -143,39 +144,53 @@ static class ManifestReadTask extends BaseFileScanTask
implements DataTask {
private final FileIO io;
private final Map<Integer, PartitionSpec> specsById;
private final ManifestFile manifest;
- private final Schema schema;
+ private final Schema dataTableSchema;
+ private final Schema projectedSchema;
ManifestReadTask(
Table table,
ManifestFile manifest,
- Schema schema,
+ Schema projectedSchema,
String schemaString,
String specString,
ResidualEvaluator residuals) {
super(DataFiles.fromManifest(manifest), null, schemaString, specString,
residuals);
this.io = table.io();
this.specsById = Maps.newHashMap(table.specs());
this.manifest = manifest;
- this.schema = schema;
+ this.dataTableSchema = table.schema();
+ this.projectedSchema = projectedSchema;
}
@Override
public CloseableIterable<StructLike> rows() {
- return CloseableIterable.transform(manifestEntries(), file ->
(StructLike) file);
+ Set<Integer> projectedIds =
TypeUtil.getProjectedIds(DataFile.READABLE_METRICS.type());
+ Schema fileProjection = TypeUtil.selectNot(projectedSchema,
projectedIds);
+ if (projectedSchema.findColumnName(DataFile.READABLE_METRICS.fieldId())
== null) {
+ return CloseableIterable.transform(files(fileProjection), file ->
(StructLike) file);
+ } else {
+ return CloseableIterable.transform(
+ files(fileProjection), file -> wrapWithMetrics(file,
fileProjection));
+ }
}
- private CloseableIterable<? extends ContentFile<?>> manifestEntries() {
+ private CloseableIterable<? extends ContentFile<?>> files(Schema
fileProjection) {
Review Comment:
Not strictly necessarily but thought its cleaner as now passing a projection
with only fields directly from the file
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]