-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Hive: Add View support for HIVE catalog #8907
Conversation
api/src/main/java/org/apache/iceberg/exceptions/NoSuchIcebergViewException.java
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveViewCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveViewCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/HiveMetastoreSetup.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java
Outdated
Show resolved
Hide resolved
dc5d0c7
to
b3c8edc
Compare
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalogUtil.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/iceberg/view/ViewCatalogTests.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java
Outdated
Show resolved
Hide resolved
8625c9d
to
aaaa9a4
Compare
core/src/test/java/org/apache/iceberg/view/ViewCatalogTests.java
Outdated
Show resolved
Hide resolved
core/src/test/java/org/apache/iceberg/view/ViewCatalogTests.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalogUtil.java
Outdated
Show resolved
Hide resolved
table = metaClients.run(client -> client.getTable(database, tableName)); | ||
HiveOperationsBase.validateTableOrViewIsIceberg(table, fullName); | ||
|
||
if (table.getTableType().equalsIgnoreCase(TableType.VIRTUAL_VIEW.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.
If Hive Table is not iceberg table new metadataLocation should always be null.
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.
IIRC the decision was to do not use the HMS tableType for this. Shouldn't we use BaseMetastoreTableOperations.TABLE_TYPE_PROP
property instead?
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.
if (!table.getTableType().equalsIgnoreCase(TableType.VIRTUAL_VIEW.name())) { | ||
throw new NoSuchObjectException(); | ||
} |
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 throw the final exception immediately?
@ajantha-bhat / @pvary I think only major comment left here is Should we use lock before committing view table or not ? If yes should we do with this PR ? |
@nk1506: Not just major, I want to conclude on all the comments that are open. So, we can move forward. |
I agree that we do need these improvements for views
But I don't think we should drag the view support for Hive catalog since REST, Nessie, JDBC already supports it. @pvary, @rdblue, @jbonofre, @nastra : What is your opinion on this? |
I have created an issue for abstracting out ViewMetadata and TableMetadata. |
It makes sense to me to split in two parts:
|
I am not sure that I would like to support a feature in production where manual cleanup is needed after deleting an object. |
@pvary I agree. Maybe I wasn't clear, my point was:
So, if you propose the later, I agree and it should be part of this PR. For the first point, not blocker for this PR and other PRs related to views. |
If the community decides against abstracting out the common part of the Metadata, then we can decide how to handle the situation. On the other hand, until the discussion is ongoing, I would not run ahead with a hopefully temporary solution. |
.filter( | ||
table -> | ||
table.getParameters() != null | ||
&& BaseMetastoreTableOperations.ICEBERG_TABLE_TYPE_VALUE |
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'm concerned that this is changing behavior for the catalog. There was no filter on external table types previously and I don't believe that was actually required.
|
||
// If we try to create the view but the metadata location is already set, then we had a | ||
// concurrent commit | ||
if (newView |
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 check doesn't look correct. If this is a newView
there shouldn't be an existing view definition. What if this is an existing hive view that does not have a location set? It seems that this should fail if a view is found but you're attempting to create a new one.
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.
As far as I can tell, I think this is borrowed from the HiveTableOperations::doCommit() code. There it makes a bit more sense as we get a lock, do a check, then fail if there's an existing table (before we write our table).
It seems the change to abstract out common logic is in https://github.com/apache/iceberg/pull/9461/files
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 tried to follow the table behaviour . How concurrent commits will be different in case of View ? Am i missing something here?
LOG.debug("Committing existing view: {}", fullName); | ||
} else { | ||
view = | ||
newHmsTable( |
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 creating the table/view definition in hms, we should be setting something in the original and expanded text fields to indicate that this is an Iceberg view. This can help if something non-iceberg attempts to load the view definition.
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.
Should we read this from metadata properties or add a constant ?
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.
Look forward to this pr. Looks like some of this is pending #9461, so will sense for me to look at that first
@@ -284,7 +284,7 @@ private Map<String, String> tableOverrideProperties() { | |||
} | |||
} | |||
|
|||
protected static String fullTableName(String catalogName, TableIdentifier identifier) { | |||
public static String fullTableName(String catalogName, TableIdentifier identifier) { |
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.
Looks a bit strange to have a util class in Base class, can we move it to some util (for example, CatalogUtil?)
|
||
// If we try to create the view but the metadata location is already set, then we had a | ||
// concurrent commit | ||
if (newView |
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.
As far as I can tell, I think this is borrowed from the HiveTableOperations::doCommit() code. There it makes a bit more sense as we get a lock, do a check, then fail if there's an existing table (before we write our table).
It seems the change to abstract out common logic is in https://github.com/apache/iceberg/pull/9461/files
if (currentMetadataLocation() != null && !currentMetadataLocation().isEmpty()) { | ||
parameters.put(PREVIOUS_METADATA_LOCATION_PROP, currentMetadataLocation()); | ||
} | ||
parameters.put(TABLE_TYPE_PROP, ICEBERG_TABLE_TYPE_VALUE.toUpperCase(Locale.ENGLISH)); |
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.
Shouldn't this should be view property?
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 in case of Hive-Table is should be always ICEBERG_TABLE_TYPE_VALUE = "iceberg";
Closing this PR as same has been addressed with ongoing PR . |
Issues #8698