difin commented on code in PR #6449:
URL: https://github.com/apache/hive/pull/6449#discussion_r3189940321
##########
iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/MetastoreUtil.java:
##########
@@ -148,6 +153,65 @@ 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());
+ result.setTableName(tableName.getTable());
+ result.setTableType(TableType.VIRTUAL_VIEW.toString());
+
+ ViewMetadata metadata = ((BaseView) view).operations().current();
+ String sqlText = viewSqlText(view, metadata);
+ result.setViewOriginalText(sqlText);
+ result.setViewExpandedText(sqlText);
+
+ long nowMillis = System.currentTimeMillis();
+ int nowSec = (int) (nowMillis / 1000);
+ String owner =
+ PropertyUtil.propertyAsString(
+ metadata.properties(), HiveCatalog.HMS_TABLE_OWNER,
System.getProperty("user.name"));
+ result.setOwner(owner);
+ result.setCreateTime(nowSec);
+ result.setLastAccessTime(nowSec);
+ result.setRetention(Integer.MAX_VALUE);
+
+ boolean hiveEngineEnabled = false;
Review Comment:
`hiveEngineEnabled` switches how `HiveOperationsBase.storageDescriptor`
fills the Storage Desacriptor: with `HiveIcebergInputFormat /
HiveIcebergOutputFormat / HiveIcebergSerDe` when true, or the usual placeholder
`FileInputFormat / FileOutputFormat / LazySimpleSerDe` when false.
Why it’s false in `toHiveView`:
This path materializes an HMS `VIRTUAL_VIEW` for REST/other clients that
expose Iceberg view metadata through the HMS API. That row isn’t meant to drive
a Hive table scan the way a real Iceberg table commit does; execution still
comes from the view definition / catalog, not from wiring Iceberg MR formats on
the stub. `HiveViewOperations` does the same thing (hiveEngineEnabled = false).
So we keep a minimal SD consistent with normal virtual views and avoid
implying this HMS object is an Iceberg-backed table for the Hive engine. For
tables, `HiveTableOperations` still turns engine integration on/off via
metadata + `ConfigProperties.ENGINE_HIVE_ENABLED` where that actually matters.
--
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]