RussellSpitzer commented on a change in pull request #3164: URL: https://github.com/apache/iceberg/pull/3164#discussion_r714304303
########## File path: data/src/test/java/org/apache/iceberg/io/TestPartitioningWriters.java ########## @@ -0,0 +1,535 @@ +/* + * 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.io; + +import java.io.File; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.List; +import org.apache.iceberg.AssertHelpers; +import org.apache.iceberg.DataFile; +import org.apache.iceberg.FileFormat; +import org.apache.iceberg.PartitionSpec; +import org.apache.iceberg.RowDelta; +import org.apache.iceberg.Schema; +import org.apache.iceberg.deletes.PositionDelete; +import org.apache.iceberg.expressions.Expressions; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList; +import org.apache.iceberg.util.StructLikeSet; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public abstract class TestPartitioningWriters<T> extends WriterTestBase<T> { + + @Parameterized.Parameters(name = "FileFormat={0}") + public static Object[] parameters() { + return new Object[][] { + new Object[]{FileFormat.AVRO}, + new Object[]{FileFormat.PARQUET}, + new Object[]{FileFormat.ORC}, + }; + } + + private static final int TABLE_FORMAT_VERSION = 2; + private static final long TARGET_FILE_SIZE = 128L * 1024 * 1024; + + private final FileFormat fileFormat; + private OutputFileFactory fileFactory = null; + + public TestPartitioningWriters(FileFormat fileFormat) { + super(TABLE_FORMAT_VERSION); + this.fileFormat = fileFormat; + } + + protected abstract StructLikeSet toSet(Iterable<T> records); + + protected FileFormat format() { + return fileFormat; + } + + @Before + public void setupTable() throws Exception { + this.tableDir = temp.newFolder(); + Assert.assertTrue(tableDir.delete()); // created during table creation + + this.metadataDir = new File(tableDir, "metadata"); + this.table = create(SCHEMA, PartitionSpec.unpartitioned()); + this.fileFactory = OutputFileFactory.builderFor(table, 1, 1).format(fileFormat).build(); + } + + @Test + public void testClusteredDataWriterNoRecords() throws IOException { + FileWriterFactory<T> writerFactory = newWriterFactory(table.schema()); + ClusteredDataWriter<T> writer = new ClusteredDataWriter<>( + writerFactory, fileFactory, table.io(), + fileFormat, TARGET_FILE_SIZE); + + writer.close(); Review comment: Why do we close the writer twice? -- 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]
