Skip to content

Conversation

@rdblue
Copy link
Contributor

@rdblue rdblue commented Jun 28, 2019

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.

null,
ICEBERG_TABLE_TYPE_VALUE);
TableType.EXTERNAL_TABLE.toString());
tbl.getParameters().put("EXTERNAL", "TRUE"); // using the external table type also requires this
Copy link
Contributor Author

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.

Copy link
Contributor

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!

Copy link
Contributor

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)?

Copy link
Contributor Author

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.

Copy link
Contributor

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)?

Copy link
Contributor Author

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.

Copy link
Contributor

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)

Copy link
Contributor Author

@rdblue rdblue Jun 29, 2019

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);
Copy link
Contributor Author

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.

Copy link
Contributor

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);
Copy link
Contributor

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.

@aokolnychyi
Copy link
Contributor

Shall we use HiveCatalog in #239?

@rdblue
Copy link
Contributor Author

rdblue commented Jun 28, 2019

@aokolnychyi, we should eventually. This and #239 are mostly independent changes, so let's make that change in the PR that gets merged last.

@rdblue rdblue force-pushed the add-catalog-implementation branch from b0eb257 to 2ed46bd Compare June 28, 2019 16:09
@aokolnychyi
Copy link
Contributor

LGTM

@danielcweeks
Copy link
Contributor

Minor comment. Other than that +1


try {
clients.run(client -> {
client.dropTable(database, identifier.name());
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.)

Copy link
Contributor Author

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.

@rdblue rdblue force-pushed the add-catalog-implementation branch from cc5c42e to 648b4c0 Compare June 29, 2019 04:47
@rdblue rdblue force-pushed the add-catalog-implementation branch from 648b4c0 to 757fee8 Compare June 29, 2019 14:05
@rdblue rdblue merged commit e133f53 into apache:master Jun 29, 2019
@aokolnychyi
Copy link
Contributor

aokolnychyi commented Jun 30, 2019

@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 BaseMetastoreTableOperations.

@rdblue
Copy link
Contributor Author

rdblue commented Jul 3, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants