kasakrisz commented on code in PR #6449:
URL: https://github.com/apache/hive/pull/6449#discussion_r3233440045


##########
iceberg/iceberg-handler/src/test/queries/positive/iceberg_rest_catalog_gravitino.q:
##########
@@ -74,6 +72,54 @@ VALUES ('fn1','ln1', 1, 10), ('fn2','ln2', 2, 20), 
('fn3','ln3', 3, 30);
 describe formatted ice_orc2;
 select * from ice_orc2;
 
+---------------------------------------------------------------------------------------------------------------------
+--! Iceberg Native View tests
+---------------------------------------------------------------------------------------------------------------------
+
+-- Enable once CBO supports Iceberg native views on partitioned tables
+set hive.cbo.enable=false;  
+
+-----------------------------------------------------------------------------------------------
+--! Iceberg native view via TBLPROPERTIES ('view-format'='iceberg') on a REST 
catalog table
+--! without a catalog name in table properties
+-----------------------------------------------------------------------------------------------
+
+create view ice_v1 tblproperties ('view-format'='iceberg') as select * from 
ice_orc1;
+select * from ice_v1;
+desc formatted ice_v1;
+drop view ice_v1;
+
+-----------------------------------------------------------------------------------------------
+--! Iceberg native view via TBLPROPERTIES ('view-format'='iceberg') on a REST 
catalog table
+--! with a catalog name in table properties
+-----------------------------------------------------------------------------------------------
+
+create view ice_v2 tblproperties ('view-format'='iceberg') as select * from 
ice_orc2;
+select * from ice_v2;
+desc formatted ice_v2;
+drop view ice_v2;
+
+-----------------------------------------------------------------------------------------------
+--! Native Iceberg catalog view: STORED BY omitted, 
'hive.default.storage.handler.class' set to
+--! HiveIcebergStorageHandler on a REST catalog table without catalog name in 
table properties
+-----------------------------------------------------------------------------------------------
+
+set 
hive.default.storage.handler.class=org.apache.iceberg.mr.hive.HiveIcebergStorageHandler;
+
+create view ice_v3 as select * from ice_orc1;
+select * from ice_v3;
+desc formatted ice_v3;
+drop view ice_v3;
+
+-----------------------------------------------------------------------------------------------
+--! Native Iceberg catalog view with default Iceberg storage handler (REST 
table with catalog in props)
+-----------------------------------------------------------------------------------------------
+
+create view ice_v4 as select * from ice_orc2;
+select * from ice_v4;
+desc formatted ice_v4;
+drop view ice_v4;

Review Comment:
   Thanks for the clarification. Is it mean that the view `ice_v4` is created 
in the `ice01` catalog too ?
   
   Does creating views in one catalog referencing base tables from another 
catalog?
   
   [difin] - there was no option to reply on this comment, see reply below.



##########
iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/MetastoreUtil.java:
##########
@@ -148,6 +153,74 @@ public static Table toHiveTable(org.apache.iceberg.Table 
table, Configuration co
     return result;
   }
 
+  /**
+   * Builds a Hive metastore {@link Table} representation for an Iceberg 
{@link View}, for clients
+   * (e.g. {@code HiveRESTCatalogClient}) that bridge Iceberg catalog metadata 
into the HMS API.
+   */
+  public static Table toHiveView(View view, Configuration conf) {
+    Table result = new Table();
+    TableName tableName =
+        TableName.fromString(
+            view.name(), MetaStoreUtils.getDefaultCatalog(conf), 
Warehouse.DEFAULT_DATABASE_NAME);
+    result.setCatName(tableName.getCat());
+    result.setDbName(tableName.getDb());

Review Comment:
   Sorry, my question was inspired by the fact that the database name is 
hardcoded, which makes it impossible to handle views in databases other than 
'default'.
   
   > this method is only called when reading from a view using a REST Catalog - 
it is called from `HiveRESTCatalogClient.getTable(GetTableRequest tableRequest)`
   
   Does this imply that I am unable to reference views from any database other 
than `default` ?
   ```
   select * from my_db.my_view;
   ```
   [difin] - there was no option to reply on this comment, see reply below.
   
   



-- 
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]

Reply via email to