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


##########
core/src/main/java/org/apache/gravitino/catalog/PropertiesMetadataHelpers.java:
##########
@@ -54,25 +54,31 @@ public static void validatePropertyForCreate(
             .collect(Collectors.toList());
     Preconditions.checkArgument(
         reservedProperties.isEmpty(),
-        "Properties are reserved and cannot be set: %s",
+        "Properties or properties with a fixed prefix are reserved and cannot 
be set: %s",
         reservedProperties);
 
     List<String> absentProperties =
-        propertiesMetadata.propertyEntries().keySet().stream()
-            .filter(propertiesMetadata::isRequiredProperty)
-            .filter(k -> !properties.containsKey(k))
+        propertiesMetadata.propertyEntries().values().stream()
+            .filter(PropertyEntry::isRequired)
+            .filter(
+                e ->
+                    (!e.isPrefix() && !properties.containsKey(e.getName()))
+                        || (e.isPrefix()
+                            && properties.keySet().stream()
+                                .noneMatch(k -> k.startsWith(e.getName()))))
+            .map(PropertyEntry::getName)
             .collect(Collectors.toList());
     Preconditions.checkArgument(
         absentProperties.isEmpty(),
-        "Properties are required and must be set: %s",
+        "Properties or properties with a fixed prefix are required and must be 
set: %s",

Review Comment:
   I can't get `Properties or properties with a fixed prefix are required`. 
According to your code, it should be `Required properties should be set or 
required prefix properties should be set with prefixes in the key`.



##########
core/src/main/java/org/apache/gravitino/connector/PropertiesMetadata.java:
##########
@@ -102,10 +149,34 @@ default Object getOrDefault(Map<String, String> 
properties, String propertyName)
    * @return the default value object of the property.
    */
   default Object getDefaultValue(String propertyName) {
+    PropertyEntry<?> propertyEntry = getPropertyEntry(propertyName);
+
+    return propertyEntry.getDefaultValue();
+  }
+
+  /**
+   * Get the property entry of the property.
+   *
+   * @param propertyName The name of the property.
+   * @return the property entry object of the property.
+   * @throws IllegalArgumentException if the property is not defined.
+   */
+  default PropertyEntry<?> getPropertyEntry(String propertyName) throws 
IllegalArgumentException {

Review Comment:
   Can you provide more comments on this method?  will we get the value of the 
longest key for prefix property and why?



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