mchades commented on code in PR #9016:
URL: https://github.com/apache/gravitino/pull/9016#discussion_r2493746134
##########
lance/lance-common/src/main/java/org/apache/gravitino/lance/common/ops/gravitino/GravitinoLanceNamespaceWrapper.java:
##########
@@ -631,36 +649,39 @@ public RegisterTableResponse registerTable(
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 = null;
+ try {
+ tableProperties.put("format", "lance");
+ t =
+ catalog
+ .asTableCatalog()
+ .createTable(tableIdentifier, new Column[] {}, null,
tableProperties);
+ } catch (TableAlreadyExistsException exception) {
+ if (mode == RegisterTableRequest.ModeEnum.CREATE) {
+ throw LanceNamespaceException.conflict(
+ "Table already exists: " + tableId,
+ TableAlreadyExistsException.class.getSimpleName(),
+ tableId,
+ CommonUtil.formatCurrentStackTrace());
+ } else if (mode == RegisterTableRequest.ModeEnum.OVERWRITE) {
+ LOG.info("Overwriting existing table: {}", tableId);
+ catalog.asTableCatalog().dropTable(tableIdentifier);
Review Comment:
alright, the OAS seems not describe how to handle the data of the existing
table
--
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]