mchades commented on code in PR #8964:
URL: https://github.com/apache/gravitino/pull/8964#discussion_r2481444165
##########
lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceNamespaceWrapper.java:
##########
@@ -614,6 +610,68 @@ public CreateTableResponse createTable(
return response;
}
+ @Override
+ public RegisterTableResponse registerTable(
+ String tableId, String mode, String delimiter, Map<String, String>
tableProperties) {
+ ObjectIdentifier nsId = ObjectIdentifier.of(tableId,
Pattern.quote(delimiter));
+ Preconditions.checkArgument(
+ nsId.levels() <= 3, "Expected at most 3-level namespace but got: %s",
nsId.levels());
+
+ String catalogName = nsId.levelAtListPos(0);
+ Catalog catalog = loadAndValidateLakehouseCatalog(catalogName);
+ NameIdentifier tableIdentifier =
+ NameIdentifier.of(nsId.levelAtListPos(1), nsId.levelAtListPos(2));
+
+ // TODO Support real register API
+ RegisterTableRequest.ModeEnum createMode =
+ RegisterTableRequest.ModeEnum.fromValue(mode.toUpperCase());
+ if (createMode == RegisterTableRequest.ModeEnum.CREATE
+ && catalog.asTableCatalog().tableExists(tableIdentifier)) {
+ throw LanceNamespaceException.conflict(
+ "Table already exists: " + tableId,
+ SchemaAlreadyExistsException.class.getSimpleName(),
+ tableId,
+ CommonUtil.formatCurrentStackTrace());
+ }
+
+ if (createMode == RegisterTableRequest.ModeEnum.OVERWRITE
+ && catalog.asTableCatalog().tableExists(tableIdentifier)) {
+ LOG.info("Overwriting existing table: {}", tableId);
+ catalog.asTableCatalog().dropTable(tableIdentifier);
+ }
+
+ Table t =
+ catalog.asTableCatalog().createTable(tableIdentifier, new Column[] {},
"", tableProperties);
+
+ RegisterTableResponse response = new RegisterTableResponse();
+ response.setProperties(t.properties());
+ response.setLocation(t.properties().get("location"));
+ return response;
+ }
+
+ @Override
+ public DeregisterTableResponse deregisterTable(String tableId, String
delimiter) {
+
+ ObjectIdentifier nsId = ObjectIdentifier.of(tableId,
Pattern.quote(delimiter));
+ Preconditions.checkArgument(
+ nsId.levels() <= 3, "Expected at most 3-level namespace but got: %s",
nsId.levels());
Review Comment:
should be equals to 3 level?
--
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]