szehon-ho commented on code in PR #4812: URL: https://github.com/apache/iceberg/pull/4812#discussion_r910268613
########## core/src/main/java/org/apache/iceberg/PositionDeletesTableScan.java: ########## @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iceberg; + +import org.apache.iceberg.expressions.Expression; +import org.apache.iceberg.expressions.Expressions; +import org.apache.iceberg.expressions.ResidualEvaluator; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.util.PropertyUtil; + +public class PositionDeletesTableScan extends BaseMetadataTableScan { + + public PositionDeletesTableScan(TableOperations ops, Table table, Schema schema) { + super(ops, table, schema, MetadataTableType.POSITION_DELETES); + } + + PositionDeletesTableScan(TableOperations ops, Table table, Schema schema, TableScanContext context) { + super(ops, table, schema, MetadataTableType.POSITION_DELETES, context); + } + + @Override + protected TableScan newRefinedScan(TableOperations ops, Table table, Schema schema, TableScanContext context) { + return new PositionDeletesTableScan(ops, table, schema, context); + } + + @Override + protected CloseableIterable<FileScanTask> doPlanFiles() { + // TODO- add partition column and implement filter push down + boolean ignoreResiduals = context().ignoreResiduals(); + String schemaString = SchemaParser.toJson(tableSchema()); + Expression filter = ignoreResiduals ? Expressions.alwaysTrue() : context().rowFilter(); + ResidualEvaluator residuals = ResidualEvaluator.unpartitioned(filter); + DeleteFileIndex deleteIndex = DeleteFileIndex.builderFor(tableOps().io(), snapshot().deleteManifests()) + .specsById(table().specs()) + .build(); + + CloseableIterable<DeleteFile> deleteFiles = CloseableIterable.withNoopClose(deleteIndex.referencedDeleteFiles()); + CloseableIterable<DeleteFile> positionDeleteFiles = CloseableIterable.filter(deleteFiles, + df -> df.content().equals(FileContent.POSITION_DELETES)); + return CloseableIterable.transform(positionDeleteFiles, f -> { + PartitionSpec spec = table().specs().get(f.specId()); + String specString = PartitionSpecParser.toJson(spec); + return new BaseFileScanTask(DataFiles.fromPositionDelete(f, spec), Review Comment: So I spent a bit of time on this to implement a PositionDeletesScanTask, but it still does not work yet. TableScan still returns FileScanTask, so unless we change the interface I am not sure how this will get passed to Spark (Table.newScan is used everywhere to get TableScans). I think this is possible like in my first commit https://github.com/apache/iceberg/pull/4812/files/051014682a2e876d2d5a7cb0b545bb5c1f8fa171 by making a new method on FileScanTask (alternatively, maybe we can add a new method on Table to return a parameterized Scan), but I guess it's not as clean. -- 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]
