yuqi1129 commented on code in PR #9279:
URL: https://github.com/apache/gravitino/pull/9279#discussion_r2570338330


##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableOperations.java:
##########
@@ -100,45 +109,59 @@ public Table createTable(
     String location = properties.get(Table.PROPERTY_LOCATION);
     Preconditions.checkArgument(
         StringUtils.isNotBlank(location), "Table location must be specified");
-    Map<String, String> storageProps = 
LancePropertiesUtils.getLanceStorageOptions(properties);
+
+    // Extract creation mode from properties
+    CreationMode mode =
+        Optional.ofNullable(properties.get(LANCE_CREATION_MODE))
+            .map(
+                modeStr -> {
+                  try {
+                    return CreationMode.valueOf(modeStr);
+                  } catch (IllegalArgumentException e) {
+                    throw new IllegalArgumentException(
+                        "Invalid creation mode: "
+                            + modeStr
+                            + ". Supported modes are CREATE, EXIST_OK, "
+                            + "OVERWRITE.");
+                  }
+                })
+            .orElse(CreationMode.CREATE);
 
     boolean register =
-        
Optional.ofNullable(properties.get(LanceTableDelegator.PROPERTY_LANCE_TABLE_REGISTER))
+        Optional.ofNullable(properties.get(LANCE_TABLE_REGISTER))
             .map(Boolean::parseBoolean)
             .orElse(false);
-    if (register) {
-      // If this is a registration operation, just create the table metadata 
without creating a new
-      // dataset
-      return super.createTable(
-          ident, columns, comment, properties, partitions, distribution, 
sortOrders, indexes);
+
+    // Handle EXIST_OK mode - check if table exists first
+    if (mode == CreationMode.EXIST_OK) {

Review Comment:
   I remember that only modes `create` and `overwrite` are allowed for 
registering a table. 



##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableOperations.java:
##########
@@ -100,45 +109,59 @@ public Table createTable(
     String location = properties.get(Table.PROPERTY_LOCATION);
     Preconditions.checkArgument(
         StringUtils.isNotBlank(location), "Table location must be specified");
-    Map<String, String> storageProps = 
LancePropertiesUtils.getLanceStorageOptions(properties);
+
+    // Extract creation mode from properties
+    CreationMode mode =
+        Optional.ofNullable(properties.get(LANCE_CREATION_MODE))
+            .map(
+                modeStr -> {
+                  try {
+                    return CreationMode.valueOf(modeStr);
+                  } catch (IllegalArgumentException e) {
+                    throw new IllegalArgumentException(

Review Comment:
   I'm not very sure about the intention that `catch IllegalArgumentException 
and then throw an IllegalArgumentException` 



##########
catalogs/catalog-lakehouse-generic/src/main/java/org/apache/gravitino/catalog/lakehouse/lance/LanceTableDelegator.java:
##########
@@ -44,20 +43,28 @@ public String tableFormat() {
   public List<PropertyEntry<?>> tablePropertyEntries() {
     return ImmutableList.of(
         PropertyEntry.stringOptionalPropertyPrefixEntry(
-            PROPERTY_LANCE_STORAGE_OPTIONS_PREFIX,
+            LANCE_STORAGE_OPTIONS_PREFIX,
             "The storage options passed to Lance table.",
             false /* immutable */,
             null /* default value*/,
             false /* hidden */,
             false /* reserved */),
         PropertyEntry.booleanPropertyEntry(
-            PROPERTY_LANCE_TABLE_REGISTER,
+            LANCE_TABLE_REGISTER,
             "Whether this is a table registration operation.",
             false,
             true /* immutable */,
             false /* defaultValue */,
             false /* hidden */,
-            false));
+            false),
+        PropertyEntry.stringPropertyEntry(

Review Comment:
   I would suggest you use an enum type property.



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

Reply via email to