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

Core: JDBCCatalog's dropView() should purge metadata files if GC is enabled #12511

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hsiang-c
Copy link
Contributor

@github-actions github-actions bot added the core label Mar 13, 2025
@hsiang-c
Copy link
Contributor Author

cc @jbonofre @ajantha-bhat Please take a look for me, thanks.

import java.sql.SQLException;
import java.util.Map;
import java.util.UUID;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't be a Hadoop Path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @nastra, I replace it with java.io.File.

File currentMetadataLocation = new File(metadataFileLocation);

catalog.dropView(identifier);
assertThat(currentMetadataLocation.exists()).isTrue();
Copy link
Contributor

Choose a reason for hiding this comment

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

AssertJ has a method to verify a file existence:

Suggested change
assertThat(currentMetadataLocation.exists()).isTrue();
assertThat(currentMetadataLocation).exists();

File currentMetadataLocation = new File(metadataFileLocation);

catalog.dropView(identifier);
assertThat(currentMetadataLocation.exists()).isFalse();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assertThat(currentMetadataLocation.exists()).isFalse();
assertThat(currentMetadataLocation).doesNotExist();

@@ -138,4 +142,50 @@ public void testCommitExceptionWithMessage() {
.hasMessageStartingWith("View already exists: " + identifier);
}
}

@Test
public void dropViewShouldNotDropMetadataFileIfGcNotEnabled() throws IOException {
Copy link
Contributor

@ebyhr ebyhr Mar 14, 2025

Choose a reason for hiding this comment

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

Why not add these tests to ViewCatalogTests? Also, throws IOException is redundant.

ViewMetadata lastViewMetadata = null;
try {
lastViewMetadata = ops.current();
} catch (NotFoundException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When does ops.current() method throw NotFoundException? I think it throws NoSuchViewException.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants