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

API: Add name to Table and Catalog APIs #1537

Merged
merged 4 commits into from
Oct 1, 2020

Conversation

aokolnychyi
Copy link
Contributor

@aokolnychyi aokolnychyi commented Oct 1, 2020

This PR adds name methods to the Table and Catalog APIs.

Resolves #658.

*
* @return this catalog's name
*/
default String name() {
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 did not intend to add the name to the Catalog API but we need this for proper metadata table names.

*
* @return this table's name
*/
default String name() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is debatable whether we have to default this. I did this to avoid breaking custom implementations.

@@ -59,10 +59,10 @@ public static Table createMetadataTableInstance(TableOperations originTableOps,
}

public static Table createMetadataTableInstance(TableOperations originTableOps,
String catalogName,
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 was broken before as the name of the metadata table started with its type, not catalog.

String location = tableDir.toURI().toString();
TABLES.create(SCHEMA, spec, location);

Table table = TABLES.load(location);
Copy link
Contributor Author

@aokolnychyi aokolnychyi Oct 1, 2020

Choose a reason for hiding this comment

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

Metadata tables loaded through HadoopTables will have their names as location.type (which is weird as we normally use location#type). I am not sure whether it is a big deal or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think ideally you would be able to use the result of name to load the table. I'd prefer to fix it if we can. Maybe we should pass the full metadata table name in, rather than having it added by the table implementation.

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 fixed it but it did require substantially more changes.

String name = identifier.name();
MetadataTableType type = MetadataTableType.from(name);
String tableName = identifier.name();
MetadataTableType type = MetadataTableType.from(tableName);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why rename 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.

We use name() a few lines below now. I think it will be confusing to have name() that is the catalog name and name that is the metadata table name in the same method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, but if this is the metadata table name (e.g. "files") instead of the table name, I think it might make more sense to be specific: metadataName?

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 feel like the current way is a bit more consistent with the overall structure of the method: the method name is loadMetadataTable and we use baseTableIdentifier to refer to the base table.

Copy link
Contributor

@rdblue rdblue left a comment

Choose a reason for hiding this comment

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

Overall looks good. I had some comments, but there aren't any blockers.

@aokolnychyi
Copy link
Contributor Author

Thanks for the review, @rdblue. I went ahead and updated minor comments as well.

@aokolnychyi aokolnychyi merged commit ed9caa8 into apache:master Oct 1, 2020
@rdblue rdblue added this to the Java 0.10.0 Release milestone Nov 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider add friendly name() method in Iceberg Table Interface
2 participants