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

Don't delete Hive and Iceberg schema locations with nonempty subdirectories #10485

Merged
merged 2 commits into from
Jan 12, 2022

Conversation

jirassimok
Copy link
Member

@jirassimok jirassimok commented Jan 6, 2022

This fixes an error in #10146 and #9767 that caused files in subdirectories to be ignored when determining whether to delete schema locations when dropping Hive and Iceberg schemas.

(Any empty subdirectories will still be deleted with the schema, though.)

@cla-bot cla-bot bot added the cla-signed label Jan 6, 2022
@jirassimok jirassimok force-pushed the drop-schema-files-fixup branch 3 times, most recently from 6b62bca to 15b8e81 Compare January 7, 2022 03:21
@@ -82,19 +82,20 @@ public void testDropSchemaFilesWithLocationWithExternalFile()
{
String schemaName = "schema_with_nonempty_location_" + randomTableSuffix();
String schemaDir = warehouseDirectory + "/schema-with-nonempty-location/";
// Use subdirectory to make sure file check is recursive
String subDir = schemaDir + "subdir/";
Copy link
Member

Choose a reason for hiding this comment

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

Is there case with EMPTY subdirectory also covered (that it does not prevent schema from being deleted)?

Copy link
Member Author

@jirassimok jirassimok Jan 10, 2022

Choose a reason for hiding this comment

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

I've changed that behavior so empty directories won't be deleted, and I added a test for that as well.

@jirassimok jirassimok force-pushed the drop-schema-files-fixup branch 3 times, most recently from 39e1966 to 11aea45 Compare January 10, 2022 21:05
Comment on lines -59 to +62
String schemaName = "schema_with_empty_location_" + randomTableSuffix();
String schemaDir = warehouseDirectory + "/schema-with-empty-location/";
String schemaName = "schema_without_location_" + randomTableSuffix();
String schemaDir = format("%s/%s.db/", warehouseDirectory, schemaName);

onTrino().executeQuery(format("CREATE SCHEMA %s WITH (location = '%s')", schemaName, schemaDir));
onTrino().executeQuery(format("CREATE SCHEMA %s", schemaName));
Copy link
Member Author

Choose a reason for hiding this comment

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

These lines aren't actually changed; I just switched the order of this test and the next after renaming them, and they're so similar that git didn't realize.

hdfsClient.delete(schemaDir);
}

@Test // make sure empty directories are noticed as well
Copy link
Member

Choose a reason for hiding this comment

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

nit move the comment to method body.

@losipiuk
Copy link
Member

@jirassimok error-prone-checks is failing.

Previously, files in subdirectories weren't considered when deciding
whether to delete Hive and Iceberg schema locations when the schema
was dropped.
@losipiuk losipiuk merged commit 6e16db2 into trinodb:master Jan 12, 2022
@github-actions github-actions bot added this to the 369 milestone Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants