kasakrisz commented on code in PR #6449:
URL: https://github.com/apache/hive/pull/6449#discussion_r3147206271
##########
iceberg/iceberg-handler/src/test/queries/positive/iceberg_native_view.q:
##########
@@ -0,0 +1,38 @@
+-- SORT_QUERY_RESULTS
+
+create database ice_native_view_db;
+use ice_native_view_db;
+
+create table src_ice (
+ first_name string,
+ last_name string
+ )
+partitioned by (dept_id bigint)
+stored by iceberg stored as orc;
+
+insert into src_ice values ('fn1','ln1', 1);
+insert into src_ice values ('fn2','ln2', 1);
+insert into src_ice values ('fn3','ln3', 1);
+insert into src_ice values ('fn4','ln4', 1);
+insert into src_ice values ('fn5','ln5', 2);
+insert into src_ice values ('fn6','ln6', 2);
+insert into src_ice values ('fn7','ln7', 2);
+
+update src_ice set last_name = 'ln1a' where first_name='fn1';
+update src_ice set last_name = 'ln2a' where first_name='fn2';
+update src_ice set last_name = 'ln3a' where first_name='fn3';
+update src_ice set last_name = 'ln4a' where first_name='fn4';
+update src_ice set last_name = 'ln5a' where first_name='fn5';
+update src_ice set last_name = 'ln6a' where first_name='fn6';
+update src_ice set last_name = 'ln7a' where first_name='fn7';
+
+delete from src_ice where last_name in ('ln1a', 'ln2a', 'ln7a');
+
+create view v_ice as select * from src_ice stored by iceberg;
Review Comment:
IMHO think the syntax should follow materialized view syntax
https://github.com/apache/hive/blob/ee6848d2df35abcf936ae620df29f4c4caebbd5f/iceberg/iceberg-handler/src/test/queries/positive/mv_iceberg_orc2.q#L16-L17
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
##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/view/create/CreateViewAnalyzer.java:
##########
@@ -191,6 +202,40 @@ private List<FieldSchema> getPartitionColumns(List<String>
partitionColumnNames)
return partitionColumnsCopy;
}
+ /**
+ * 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 {
Review 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]