Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void testDefaultFormatVersion()
public void testV2TableRead()
{
String tableName = "test_v2_table_read" + randomNameSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT * FROM tpch.tiny.nation", 25);
assertUpdate("CREATE TABLE " + tableName + " WITH (format_version = 1) AS SELECT * FROM tpch.tiny.nation", 25);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename test to v1TableRead

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current name looks fine because the version is 2 when reading the table. We could rename to testV2UpgradedTableRead or something, but the rename isn't necessary in my opinion.

updateTableToV2(tableName);
assertQuery("SELECT * FROM " + tableName, "SELECT * FROM nation");
}
Expand All @@ -167,7 +167,7 @@ public void testV2TableWithPositionDelete()
{
String tableName = "test_v2_row_delete" + randomNameSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT * FROM tpch.tiny.nation", 25);
Table icebergTable = updateTableToV2(tableName);
Table icebergTable = loadTable(tableName);

String dataFilePath = (String) computeActual("SELECT file_path FROM \"" + tableName + "$files\" LIMIT 1").getOnlyValue();

Expand Down Expand Up @@ -200,7 +200,7 @@ public void testV2TableWithEqualityDelete()
{
String tableName = "test_v2_equality_delete" + randomNameSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT * FROM tpch.tiny.nation", 25);
Table icebergTable = updateTableToV2(tableName);
Table icebergTable = loadTable(tableName);
writeEqualityDeleteToNationTable(icebergTable, Optional.of(icebergTable.spec()), Optional.of(new PartitionData(new Long[]{1L})));
assertQuery("SELECT * FROM " + tableName, "SELECT * FROM nation WHERE regionkey != 1");
// nationkey is before the equality delete column in the table schema, comment is after
Expand All @@ -214,7 +214,7 @@ public void testV2TableWithEqualityDeleteDifferentColumnOrder()
// Specify equality delete filter with different column order from table definition
String tableName = "test_v2_equality_delete_different_order" + randomNameSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT * FROM tpch.tiny.nation", 25);
Table icebergTable = updateTableToV2(tableName);
Table icebergTable = loadTable(tableName);
writeEqualityDeleteToNationTable(icebergTable, Optional.of(icebergTable.spec()), Optional.empty(), ImmutableMap.of("regionkey", 1L, "name", "ARGENTINA"));
assertQuery("SELECT * FROM " + tableName, "SELECT * FROM nation WHERE name != 'ARGENTINA'");
// nationkey is before the equality delete column in the table schema, comment is after
Expand All @@ -229,7 +229,7 @@ public void testV2TableWithEqualityDeleteWhenColumnIsNested()
assertUpdate("CREATE TABLE " + tableName + " AS " +
"SELECT regionkey, ARRAY[1,2] array_column, MAP(ARRAY[1], ARRAY[2]) map_column, " +
"CAST(ROW(1, 2e0) AS ROW(x BIGINT, y DOUBLE)) row_column FROM tpch.tiny.nation", 25);
Table icebergTable = updateTableToV2(tableName);
Table icebergTable = loadTable(tableName);
writeEqualityDeleteToNationTable(icebergTable, Optional.of(icebergTable.spec()), Optional.of(new PartitionData(new Long[]{1L})));
assertQuery("SELECT array_column[1], map_column[1], row_column.x FROM " + tableName, "SELECT 1, 2, 1 FROM nation WHERE regionkey != 1");
}
Expand All @@ -240,7 +240,7 @@ public void testOptimizingV2TableRemovesEqualityDeletesWhenWholeTableIsScanned()
{
String tableName = "test_optimize_table_cleans_equality_delete_file_when_whole_table_is_scanned" + randomNameSuffix();
assertUpdate("CREATE TABLE " + tableName + " WITH (partitioning = ARRAY['regionkey']) AS SELECT * FROM tpch.tiny.nation", 25);
Table icebergTable = updateTableToV2(tableName);
Table icebergTable = loadTable(tableName);
Assertions.assertThat(icebergTable.currentSnapshot().summary().get("total-equality-deletes")).isEqualTo("0");
writeEqualityDeleteToNationTable(icebergTable, Optional.of(icebergTable.spec()), Optional.of(new PartitionData(new Long[]{1L})));
List<String> initialActiveFiles = getActiveFiles(tableName);
Expand All @@ -259,7 +259,7 @@ public void testOptimizingV2TableDoesntRemoveEqualityDeletesWhenOnlyPartOfTheTab
{
String tableName = "test_optimize_table_with_equality_delete_file_for_different_partition_" + randomNameSuffix();
assertUpdate("CREATE TABLE " + tableName + " WITH (partitioning = ARRAY['regionkey']) AS SELECT * FROM tpch.tiny.nation", 25);
Table icebergTable = updateTableToV2(tableName);
Table icebergTable = loadTable(tableName);
Assertions.assertThat(icebergTable.currentSnapshot().summary().get("total-equality-deletes")).isEqualTo("0");
List<String> initialActiveFiles = getActiveFiles(tableName);
writeEqualityDeleteToNationTable(icebergTable, Optional.of(icebergTable.spec()), Optional.of(new PartitionData(new Long[]{1L})));
Expand Down Expand Up @@ -304,7 +304,7 @@ public void testOptimizingV2TableWithEmptyPartitionSpec()
{
String tableName = "test_optimize_table_with_global_equality_delete_file_" + randomNameSuffix();
assertUpdate("CREATE TABLE " + tableName + " AS SELECT * FROM tpch.tiny.nation", 25);
Table icebergTable = updateTableToV2(tableName);
Table icebergTable = loadTable(tableName);
Assertions.assertThat(icebergTable.currentSnapshot().summary().get("total-equality-deletes")).isEqualTo("0");
writeEqualityDeleteToNationTable(icebergTable);
List<String> initialActiveFiles = getActiveFiles(tableName);
Expand All @@ -323,7 +323,7 @@ public void testOptimizingPartitionsOfV2TableWithGlobalEqualityDeleteFile()
{
String tableName = "test_optimize_partitioned_table_with_global_equality_delete_file_" + randomNameSuffix();
assertUpdate("CREATE TABLE " + tableName + " WITH (partitioning = ARRAY['regionkey']) AS SELECT * FROM tpch.tiny.nation", 25);
Table icebergTable = updateTableToV2(tableName);
Table icebergTable = loadTable(tableName);
Assertions.assertThat(icebergTable.currentSnapshot().summary().get("total-equality-deletes")).isEqualTo("0");
writeEqualityDeleteToNationTable(icebergTable, Optional.of(icebergTable.spec()), Optional.of(new PartitionData(new Long[]{1L})));
List<String> initialActiveFiles = getActiveFiles(tableName);
Expand Down