mchades commented on code in PR #10879:
URL: https://github.com/apache/gravitino/pull/10879#discussion_r3159031130
##########
core/src/main/java/org/apache/gravitino/catalog/ViewOperationDispatcher.java:
##########
@@ -135,22 +170,45 @@ private EntityCombinedView importView(NameIdentifier
ident) throws NoSuchViewExc
LOG.info("Auto-importing view {} into Gravitino entity store", ident);
long uid = idGenerator.nextId();
- GenericEntity newViewEntity =
- GenericEntity.builder()
- .withId(uid)
- .withName(ident.name())
- .withNamespace(ident.namespace())
- .withEntityType(Entity.EntityType.VIEW)
- .build();
+ View catalogView = entityCombinedView.viewFromCatalog();
+ ViewEntity newViewEntity = buildViewEntityForImport(uid, ident,
catalogView);
try {
store.put(newViewEntity, false /* overwrite */);
LOG.info("Successfully imported view {} into entity store with id {}",
ident, uid);
- return EntityCombinedView.of(entityCombinedView.viewFromCatalog(),
newViewEntity)
- .withImported(true);
+ return EntityCombinedView.of(catalogView,
newViewEntity).withImported(true);
} catch (Exception e) {
// Log but don't fail - view import is best-effort
LOG.warn("Failed to import view {} into entity store: {}", ident,
e.getMessage());
- return
EntityCombinedView.of(entityCombinedView.viewFromCatalog()).withImported(false);
+ return EntityCombinedView.of(catalogView).withImported(false);
}
}
+
+ private ViewEntity buildViewEntityForImport(Long uid, NameIdentifier ident,
View view) {
Review Comment:
`buildViewEntityForImport` is the materialization step in the `loadView`
auto-import path: it converts a catalog `View` into a persisted `ViewEntity`
with Gravitino-generated id/identifier.
It is similar in purpose to table import, but currently lighter than
`importTable` (no string-identifier reconciliation/rename correction path, and
import here is best-effort).
Given `ViewOperationDispatcher` currently only supports `loadView` +
auto-import, we expect to clean up/refactor this helper when full view CRUD
lands in follow-up PRs.
--
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]