Skip to content

Commit

Permalink
update columns type to list in manifest reader
Browse files Browse the repository at this point in the history
  • Loading branch information
yyanyy committed Nov 25, 2020
1 parent 684459c commit bb09e68
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/apache/iceberg/ManifestGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public CloseableIterable<FileScanTask> planFiles() {

boolean dropStats = ManifestReader.dropStats(dataFilter, columns);
if (!deleteFiles.isEmpty()) {
select(Lists.newArrayList(ManifestReader.withStatsColumns(columns)));
select(ManifestReader.withStatsColumns(columns));
}

Iterable<CloseableIterable<FileScanTask>> tasks = entries((manifest, entries) -> {
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/apache/iceberg/ManifestReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private String fileClass() {
private Expression partFilter = alwaysTrue();
private Expression rowFilter = alwaysTrue();
private Schema fileProjection = null;
private Collection<String> columns = null;
private List<String> columns = null;
private boolean caseSensitive = true;

// lazily initialized
Expand Down Expand Up @@ -143,7 +143,7 @@ public PartitionSpec spec() {
return spec;
}

public ManifestReader<F> select(Collection<String> newColumns) {
public ManifestReader<F> select(List<String> newColumns) {
Preconditions.checkState(fileProjection == null,
"Cannot select columns using both select(String...) and project(Schema)");
this.columns = newColumns;
Expand Down Expand Up @@ -296,7 +296,7 @@ static boolean dropStats(Expression rowFilter, Collection<String> columns) {
Sets.intersection(Sets.newHashSet(columns), STATS_COLUMNS).isEmpty();
}

static Collection<String> withStatsColumns(Collection<String> columns) {
static List<String> withStatsColumns(List<String> columns) {
if (columns.containsAll(ManifestReader.ALL_COLUMNS)) {
return columns;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import java.util.Map;
import org.apache.iceberg.expressions.Expressions;
import org.apache.iceberg.io.CloseableIterable;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableSet;
import org.apache.iceberg.types.Conversions;
import org.apache.iceberg.types.Types;
import org.junit.Assert;
Expand Down Expand Up @@ -88,7 +88,7 @@ public void testReadWithFilterIncludesFullStats() throws IOException {
public void testReadEntriesWithFilterAndSelectIncludesFullStats() throws IOException {
ManifestFile manifest = writeManifest(1000L, FILE);
try (ManifestReader<DataFile> reader = ManifestFiles.read(manifest, FILE_IO)
.select(ImmutableSet.of("file_path"))
.select(ImmutableList.of("file_path"))
.filterRows(Expressions.equal("id", 3))) {
CloseableIterable<ManifestEntry<DataFile>> entries = reader.entries();
ManifestEntry<DataFile> entry = entries.iterator().next();
Expand All @@ -100,7 +100,7 @@ public void testReadEntriesWithFilterAndSelectIncludesFullStats() throws IOExcep
public void testReadIteratorWithFilterAndSelectDropsStats() throws IOException {
ManifestFile manifest = writeManifest(1000L, FILE);
try (ManifestReader<DataFile> reader = ManifestFiles.read(manifest, FILE_IO)
.select(ImmutableSet.of("file_path"))
.select(ImmutableList.of("file_path"))
.filterRows(Expressions.equal("id", 3))) {
DataFile entry = reader.iterator().next();
assertStatsDropped(entry);
Expand All @@ -110,7 +110,7 @@ public void testReadIteratorWithFilterAndSelectDropsStats() throws IOException {
public void testReadIteratorWithFilterAndSelectStatsIncludesFullStats() throws IOException {
ManifestFile manifest = writeManifest(1000L, FILE);
try (ManifestReader<DataFile> reader = ManifestFiles.read(manifest, FILE_IO)
.select(ImmutableSet.of("file_path", "value_counts"))
.select(ImmutableList.of("file_path", "value_counts"))
.filterRows(Expressions.equal("id", 3))) {
DataFile entry = reader.iterator().next();
assertFullStats(entry);
Expand All @@ -121,7 +121,7 @@ public void testReadIteratorWithFilterAndSelectStatsIncludesFullStats() throws I
public void testReadEntriesWithSelectNotIncludeFullStats() throws IOException {
ManifestFile manifest = writeManifest(1000L, FILE);
try (ManifestReader<DataFile> reader = ManifestFiles.read(manifest, FILE_IO)
.select(ImmutableSet.of("file_path"))) {
.select(ImmutableList.of("file_path"))) {
CloseableIterable<ManifestEntry<DataFile>> entries = reader.entries();
ManifestEntry<DataFile> entry = entries.iterator().next();
assertNoStats(entry.file());
Expand All @@ -131,7 +131,7 @@ public void testReadEntriesWithSelectNotIncludeFullStats() throws IOException {
public void testReadEntriesWithSelectCertainStatNotIncludeFullStats() throws IOException {
ManifestFile manifest = writeManifest(1000L, FILE);
try (ManifestReader<DataFile> reader = ManifestFiles.read(manifest, FILE_IO)
.select(ImmutableSet.of("file_path", "value_counts"))) {
.select(ImmutableList.of("file_path", "value_counts"))) {
DataFile dataFile = reader.iterator().next();

Assert.assertEquals(-1, dataFile.recordCount());
Expand Down

0 comments on commit bb09e68

Please sign in to comment.