-
Notifications
You must be signed in to change notification settings - Fork 3k
Add HiveCatalog implementation #240
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
Conversation
| null, | ||
| ICEBERG_TABLE_TYPE_VALUE); | ||
| TableType.EXTERNAL_TABLE.toString()); | ||
| tbl.getParameters().put("EXTERNAL", "TRUE"); // using the external table type also requires this |
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.
@aokolnychyi, this is a new fix to make tables external so that Iceberg manages the underlying location instead of Hive. In the previous version of this PR, using a managed table caused the table location to be moved during rename, which would break Iceberg metadata. You probably want to make sure you're using this change.
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.
@rdblue yeah, we had this change internally already to be compatible with the Spark external catalog in 2.4. Thanks!
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 means the metastore won't delete the location directory when the table is dropped. In general, this seems like the right behavior, since Iceberg data can be anywhere. But for users that are only going through this interface, how is data cleaned up? Because tables are created in the default Hive location based on the name, what happens if we do a drop followed by a create (since the old data still exists)?
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.
New table data and old table data can be mixed together without corrupting the table state. The problem is that this would leave data lying around. We could add a purge option to drop the data when the table is dropped.
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.
Who is responsible for cleaning up data in the Iceberg model? Is that out of scope for the project (assumed that a complementary system handles it)?
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.
I think it should be up to the caller whether Iceberg cleans it up or leaves it for a complementary system. We have a janitor process that cleans it up, but we don't want to assume that users will. I'll add this in a follow-up issue.
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.
Just to clarify: will purge flag indicate whether to delete location in HMS or will it look into where the data and metadata actually is? (e.g. write.folder-storage.path and write.metadata.path, which can change over time)
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.
Purge would basically do the same thing as a snapshot expiration and would remove the entire tree of metadata and data files. I don't think it should delete directories because Iceberg can't necessarily assume that it owns the entire directory structure. Iceberg tables actually use the same storage locations.
|
|
||
| HiveClientPool(int poolSize, Configuration conf) { | ||
| super(poolSize, TException.class); | ||
| super(poolSize, TTransportException.class); |
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.
@aokolnychyi, this was incorrect and causing the clients to reconnect on every TException, including exceptions thrown when tables already exist or do not exist (in the existence check). You will probably want to use this change to avoid over-reconnecting.
In addition, I think that it is correct to close the client before reconnecting because with this problem I was still seeing connection exhaustion in the test metastore. Closing before reconnect fixed the problem and using TTransportException also fixed the problem independently.
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.
+1, thanks! We will pull this in.
|
|
||
| HiveClientPool(int poolSize, Configuration conf) { | ||
| super(poolSize, TException.class); | ||
| super(poolSize, TTransportException.class); |
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.
+1, thanks! We will pull this in.
|
Shall we use |
|
@aokolnychyi, we should eventually. This and #239 are mostly independent changes, so let's make that change in the PR that gets merged last. |
b0eb257 to
2ed46bd
Compare
|
LGTM |
|
Minor comment. Other than that +1 |
|
|
||
| try { | ||
| clients.run(client -> { | ||
| client.dropTable(database, identifier.name()); |
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 delegates to the longer variant with dropTable=true. We might want to call the other version explicitly, if that is not the intended behavior. Also, we should consider how this affects earlier created tables that had a table type of ICEBERG rather than EXTERNAL_TABLE.
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 doesn't actually drop the data because it is an external table. I've added a test to validate this behavior. We can add a purge option in a follow-up.
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.
My point was that this is confusing to readers, since we are asking the metastore to delete the data, but we know it won’t be deleted since it’s an external table.
And because the delete flag is set, existing Iceberg tables from before this change may have the data deleted, since they are not external tables. (I haven’t checked how metastore treats custom table types. Maybe same as external, in which case this is ok.)
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.
I'll clean this up in a follow-up that addresses delete data directly, I agree with you that we should consider tables that aren't external here. If we have a flag we can set for the expected behavior, then we should set it.
cc5c42e to
648b4c0
Compare
648b4c0 to
757fee8
Compare
|
@rdblue What about cases when we drop tables from the catalog but keep the metadata? Will it make sense to have a way to register them back by giving a location? It won't be straightforward, though. The location can be shared by multiple Iceberg tables and we also add a UUID to metadata file names in |
|
I agree with the idea to add a UUID to table metadata. I've been meaning to do that. Are you suggesting that we purge data but not metadata? |
This is based on Parth's PR #187 and implements the review comments.
This includes an implementation of the Catalog API for Hive. It also has some minor updates to the Catalog API and fixes some problems with Hive connections found in testing. Now all Hive tests successfully run using a single shared pool of 2 connections.
Closes #187.