Skip to content

Commit

Permalink
Move testOptimizeForPartitionedTable up
Browse files Browse the repository at this point in the history
Put `testOptimize` and `testOptimizeForPartitionedTable` next to each
other, and above their helpers.
  • Loading branch information
findepi authored and losipiuk committed Feb 24, 2022
1 parent 20dbfe6 commit b57a32c
Showing 1 changed file with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3240,41 +3240,6 @@ public void testOptimize()
assertUpdate("DROP TABLE " + tableName);
}

private List<String> getActiveFiles(String tableName)
{
return computeActual(format("SELECT file_path FROM \"%s$files\"", tableName)).getOnlyColumn()
.map(String.class::cast)
.collect(toImmutableList());
}

private List<String> getAllDataFilesFromTableDirectory(String tableName)
throws IOException
{
String schema = getSession().getSchema().orElseThrow();
Path tableDataDir = getDistributedQueryRunner().getCoordinator().getBaseDataDir().resolve("iceberg_data").resolve(schema).resolve(tableName).resolve("data");
try (Stream<Path> walk = Files.walk(tableDataDir)) {
return walk
.filter(Files::isRegularFile)
.filter(path -> !path.getFileName().toString().matches("\\..*\\.crc"))
.map(Path::toString)
.collect(toImmutableList());
}
}

@Test
public void testOptimizeParameterValidation()
{
assertQueryFails(
"ALTER TABLE no_such_table_exists EXECUTE OPTIMIZE",
"\\Qline 1:1: Table 'iceberg.tpch.no_such_table_exists' does not exist");
assertQueryFails(
"ALTER TABLE nation EXECUTE OPTIMIZE (file_size_threshold => '33')",
"\\QUnable to set catalog 'iceberg' table procedure 'OPTIMIZE' property 'file_size_threshold' to ['33']: size is not a valid data size string: 33");
assertQueryFails(
"ALTER TABLE nation EXECUTE OPTIMIZE (file_size_threshold => '33s')",
"\\QUnable to set catalog 'iceberg' table procedure 'OPTIMIZE' property 'file_size_threshold' to ['33s']: Unknown unit: s");
}

@Test
public void testOptimizeForPartitionedTable()
throws IOException
Expand Down Expand Up @@ -3317,6 +3282,41 @@ public void testOptimizeForPartitionedTable()
assertThat(getAllDataFilesFromTableDirectory(tableName)).containsExactlyInAnyOrderElementsOf(concat(initialFiles, updatedFiles));
}

private List<String> getActiveFiles(String tableName)
{
return computeActual(format("SELECT file_path FROM \"%s$files\"", tableName)).getOnlyColumn()
.map(String.class::cast)
.collect(toImmutableList());
}

private List<String> getAllDataFilesFromTableDirectory(String tableName)
throws IOException
{
String schema = getSession().getSchema().orElseThrow();
Path tableDataDir = getDistributedQueryRunner().getCoordinator().getBaseDataDir().resolve("iceberg_data").resolve(schema).resolve(tableName).resolve("data");
try (Stream<Path> walk = Files.walk(tableDataDir)) {
return walk
.filter(Files::isRegularFile)
.filter(path -> !path.getFileName().toString().matches("\\..*\\.crc"))
.map(Path::toString)
.collect(toImmutableList());
}
}

@Test
public void testOptimizeParameterValidation()
{
assertQueryFails(
"ALTER TABLE no_such_table_exists EXECUTE OPTIMIZE",
"\\Qline 1:1: Table 'iceberg.tpch.no_such_table_exists' does not exist");
assertQueryFails(
"ALTER TABLE nation EXECUTE OPTIMIZE (file_size_threshold => '33')",
"\\QUnable to set catalog 'iceberg' table procedure 'OPTIMIZE' property 'file_size_threshold' to ['33']: size is not a valid data size string: 33");
assertQueryFails(
"ALTER TABLE nation EXECUTE OPTIMIZE (file_size_threshold => '33s')",
"\\QUnable to set catalog 'iceberg' table procedure 'OPTIMIZE' property 'file_size_threshold' to ['33s']: Unknown unit: s");
}

@Test
public void testTargetMaxFileSize()
{
Expand Down

0 comments on commit b57a32c

Please sign in to comment.