aokolnychyi commented on a change in pull request #805: Add all_data_files, all_manifests, and all_entries metadata tables URL: https://github.com/apache/incubator-iceberg/pull/805#discussion_r382703188
########## File path: core/src/main/java/org/apache/iceberg/AllDataFilesTable.java ########## @@ -0,0 +1,149 @@ +/* + * 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 com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; +import java.io.IOException; +import java.util.Collection; +import java.util.List; +import org.apache.iceberg.exceptions.RuntimeIOException; +import org.apache.iceberg.expressions.Expression; +import org.apache.iceberg.expressions.ResidualEvaluator; +import org.apache.iceberg.io.CloseableIterable; +import org.apache.iceberg.types.TypeUtil; +import org.apache.iceberg.util.ParallelIterable; +import org.apache.iceberg.util.ThreadPools; + +/** + * A {@link Table} implementation that exposes a table's valid data files as rows. + * <p> + * A valid data file is one that is readable from any snapshot currently tracked by the table. + * <p> + * This table may return duplicate rows. + */ +public class AllDataFilesTable extends BaseMetadataTable { + private final TableOperations ops; + private final Table table; + + public AllDataFilesTable(TableOperations ops, Table table) { + this.ops = ops; + this.table = table; + } + + @Override + Table table() { + return table; + } + + @Override + String metadataTableName() { + return "all_data_files"; + } + + @Override + public TableScan newScan() { + return new AllDataFilesTableScan(ops, table, schema()); + } + + @Override + public Schema schema() { + Schema schema = new Schema(DataFile.getType(table.spec().partitionType()).fields()); + if (table.spec().fields().size() < 1) { + // avoid returning an empty struct, which is not always supported. instead, drop the partition field (id 102) + return TypeUtil.selectNot(schema, Sets.newHashSet(102)); + } else { + return schema; + } + } + + @Override + public String location() { + return table.currentSnapshot().manifestListLocation(); Review comment: The check was added recently with locality for HDFS. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
