Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deletion of ORC ACID table after running major compaction on it #10120

Merged
Show file tree
Hide file tree
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 @@ -52,7 +52,7 @@ public abstract class AbstractHiveAcidWriters
// The original file path looks like .../nnnnnnn_m(_copy_ccc)?
public static final Pattern ORIGINAL_FILE_PATH_MATCHER = Pattern.compile("(?s)(?<rootDir>.*)/(?<filename>(?<bucketNumber>[\\d]+)_(?<rest>.*)?)$");
// After compaction, the bucketPath looks like .../base_nnnnnnn(_vmmmmmmm)?/bucket_bbbbb(_aaaa)?
public static final Pattern BASE_PATH_MATCHER = Pattern.compile("(?s)(?<rootDir>.*)/(?<dirStart>base_[\\d]+(_v[\\d]+)?)/(?<filenameBase>bucket_(?<bucketNumber>[\\d]+))(?<attemptId>_[\\d]+)?$");
public static final Pattern BASE_PATH_MATCHER = Pattern.compile("(?s)(?<rootDir>.*)/(?<dirStart>base_[-]?[\\d]+(_v[\\d]+)?)/(?<filenameBase>bucket_(?<bucketNumber>[\\d]+))(?<attemptId>_[\\d]+)?$");
findepi marked this conversation as resolved.
Show resolved Hide resolved

protected final AcidTransaction transaction;
protected final OptionalInt bucketNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,17 @@ private void validateFileIsDirectlyUnderTableLocation(String tableName)
"files in %s are not directly under table location"));
}

@Test
public void testDeleteAfterMajorCompaction()
{
withTemporaryTable("test_delete_after_major_compaction", true, false, NONE, tableName -> {
onTrino().executeQuery(format("CREATE TABLE %s WITH (transactional = true) AS SELECT * FROM tpch.tiny.nation", tableName));
compactTableAndWait(MAJOR, tableName, "", new Duration(3, MINUTES));
onTrino().executeQuery(format("DELETE FROM %s", tableName));
verifySelectForTrinoAndHive(format("SELECT COUNT(*) FROM %s", tableName), "true", row(0));
});
}

private void hdfsDeleteAll(String directory)
{
if (!hdfsClient.exist(directory)) {
Expand Down