rdblue commented on a change in pull request #1497:
URL: https://github.com/apache/iceberg/pull/1497#discussion_r496882493
##########
File path: data/src/test/java/org/apache/iceberg/data/DeletesReadTest.java
##########
@@ -25,53 +25,68 @@
import org.apache.iceberg.DataFile;
import org.apache.iceberg.DeleteFile;
import org.apache.iceberg.Files;
+import org.apache.iceberg.PartitionSpec;
import org.apache.iceberg.Schema;
import org.apache.iceberg.Table;
-import org.apache.iceberg.TableTestBase;
import org.apache.iceberg.TestHelpers.Row;
-import org.apache.iceberg.io.CloseableIterable;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
+import org.apache.iceberg.types.Types;
import org.apache.iceberg.util.ArrayUtil;
import org.apache.iceberg.util.Pair;
import org.apache.iceberg.util.StructLikeSet;
import org.apache.iceberg.util.StructProjection;
+import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
-public class TestGenericReaderDeletes extends TableTestBase {
- public TestGenericReaderDeletes() {
- super(2 /* format v2 with delete files */);
- }
+import static org.apache.iceberg.types.Types.NestedField.required;
- private List<Record> records = null;
- private DataFile dataFile = null;
+public abstract class DeletesReadTest {
+ // Schema passed to create tables
+ public static final Schema SCHEMA = new Schema(
+ required(1, "id", Types.IntegerType.get()),
+ required(2, "data", Types.StringType.get())
+ );
- @Before
- public void writeTestDataFile() throws IOException {
- this.records = Lists.newArrayList();
+ // Partition spec used to create tables
+ public static final PartitionSpec SPEC = PartitionSpec.builderFor(SCHEMA)
+ .bucket("data", 16)
+ .build();
- // records all use IDs that are in bucket id_bucket=0
- GenericRecord record = GenericRecord.create(table.schema());
- records.add(record.copy("id", 29, "data", "a"));
- records.add(record.copy("id", 43, "data", "b"));
- records.add(record.copy("id", 61, "data", "c"));
- records.add(record.copy("id", 89, "data", "d"));
- records.add(record.copy("id", 100, "data", "e"));
- records.add(record.copy("id", 121, "data", "f"));
- records.add(record.copy("id", 122, "data", "g"));
+ protected final String testTableName = "test";
+ protected Table testTable;
+ protected DataFile dataFile;
+
+ private List<Record> records;
- this.dataFile = FileHelpers.writeDataFile(table,
Files.localOutput(temp.newFile()), Row.of(0), records);
+ @Rule
+ public TemporaryFolder temp = new TemporaryFolder();
- table.newAppend()
+ @Before
+ public void prepareData() throws IOException {
+ this.testTable = createTable(testTableName, SCHEMA, SPEC);
+ generateTestData();
+ testTable.newAppend()
.appendFile(dataFile)
.commit();
}
+ @After
+ public void cleanup() throws IOException {
+ dropTable(testTableName);
+ }
+
+ protected abstract Table createTable(String name, Schema schema,
PartitionSpec spec) throws IOException;
+
+ protected abstract void dropTable(String name) throws IOException;
+
@Test
public void testEqualityDeletes() throws IOException {
- Schema deleteRowSchema = table.schema().select("data");
+ Schema deleteRowSchema = testTable.schema().select("data");
Review comment:
Renaming `table` -> `testTable` introduces unnecessary changes and
doesn't add much value. What was the rationale for doing this?
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]