HIVE-29578: Iceberg: add support for native views#6449
HIVE-29578: Iceberg: add support for native views#6449difin wants to merge 1 commit intoapache:masterfrom
Conversation
4fdad42 to
252c608
Compare
252c608 to
e10eba5
Compare
e10eba5 to
96fa476
Compare
96fa476 to
114412a
Compare
|
|
|
||
| delete from src_ice where last_name in ('ln1a', 'ln2a', 'ln7a'); | ||
|
|
||
| create view v_ice as select * from src_ice stored by iceberg; |
There was a problem hiding this comment.
IMHO think the syntax should follow materialized view syntax
I checked some other database engines (Trino, Dremio) that supports Iceberg logical views, none of them adds extra keywords to the SQL syntax but they enable define the catalog where the view should be stored and that catalog should be Iceberg
| /** | ||
| * Optional trailing {@code tableFileFormat} on CREATE VIEW: only {@code STORED BY ICEBERG} is allowed | ||
| * (no serde properties or {@code STORED AS} tail). | ||
| */ | ||
| private boolean validateOptionalViewStorageClause(ASTNode storageRoot) throws SemanticException { |
There was a problem hiding this comment.
The keywords STORED BY ICEBERG are a bit confusing because no data is actually stored in the case of logical views. Some engines do not require extra keywords to specify when creating Iceberg logical views.
If we insist on using keywords, how about something like these?
create view <view_name> viewproperties(format='iceberg')
as select...;
create view <view_name> format iceberg
as select...;
If we decide to go with the STORED BY ICEBERG keywords, please create a new grammar rule specifically for views—similar to tableFileFormat—called viewMetadataFormat. This should limit the grammar to the STORED BY <identifier> syntax. By doing this, you can eliminate the need for extra validation checks in the analyzer.
I recommend checking the configuration setting hive.default.storage.handler.class when deciding where to store the view metadata. If a storage handler is set that supports views, let's use the Storage Handler API to store the metadata.



What changes were proposed in this pull request?
Added support for Iceberg native views in Hive for both HMS and REST catalogs.
There is a limitation in the current implementation: when Hive uses a REST catalog and creates a view on a partitioned Iceberg table, querying the view only works with CBO disabled. To be addressed in a follow-up PR.
Why are the changes needed?
To support Iceberg native views. This can be especially useful for REST Catalog clients.
Does this PR introduce any user-facing change?
Yes, new HQL syntax:
create view <view_name> as select * from <src_tbl> stored by iceberg;How was this patch tested?
Created new and updated exiting unit and integration tests with Iceberg native views test cases.