-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
base: main
Are you sure you want to change the base?
Conversation
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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:
assertThat(currentMetadataLocation.exists()).isTrue(); | |
assertThat(currentMetadataLocation).exists(); |
File currentMetadataLocation = new File(metadataFileLocation); | ||
|
||
catalog.dropView(identifier); | ||
assertThat(currentMetadataLocation.exists()).isFalse(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
.
HiveCatalog
implementeddropView
in Hive: Add View support for HIVE catalog #9852 and the view metadata will be purged from storage ifTableProperties.GC_ENABLED
istrue
(default)JdbcCatalog
should also purge view metadata in the same way.