rdblue commented on a change in pull request #4011:
URL: https://github.com/apache/iceberg/pull/4011#discussion_r800239506



##########
File path: core/src/main/java/org/apache/iceberg/BaseMetastoreCatalog.java
##########
@@ -238,4 +249,63 @@ protected static String fullTableName(String catalogName, 
TableIdentifier identi
 
     return sb.toString();
   }
+
+  @Override
+  public Table createTable(
+      TableIdentifier identifier,
+      Schema schema,
+      PartitionSpec spec,
+      String location,
+      Map<String, String> properties) {
+    return buildTable(identifier, schema)
+        .withPartitionSpec(spec)
+        .withLocation(location)
+        .withProperties(updateTableProperties(properties))
+        .create();
+  }
+
+  /**
+   * Get default table properties set at Catalog level through catalog 
properties.
+   *
+   * @return default table properties specified in catalog properties
+   */
+  private Map<String, String> tableDefaultProperties() {
+    Map<String, String> props = catalogProps == null ? Collections.emptyMap() 
: catalogProps;
+
+    return props.entrySet().stream()
+        .filter(e -> 
e.getKey().toLowerCase(Locale.ROOT).startsWith(CatalogProperties.TABLE_DEFAULT_PREFIX))
+        .collect(Collectors.toMap(e -> 
e.getKey().replace(CatalogProperties.TABLE_DEFAULT_PREFIX, ""),
+            Map.Entry::getValue));
+  }
+
+  /**
+   * Get table properties that are enforced at Catalog level through catalog 
properties.
+   *
+   * @return default table properties enforced through catalog properties
+   */
+  private Map<String, String> tableOverrideProperties() {
+    Map<String, String> props = catalogProps == null ? Collections.emptyMap() 
: catalogProps;
+
+    return props.entrySet().stream()
+        .filter(e -> 
e.getKey().toLowerCase(Locale.ROOT).startsWith(CatalogProperties.TABLE_OVERRIDE_PREFIX))
+        .collect(Collectors.toMap(e -> 
e.getKey().replace(CatalogProperties.TABLE_OVERRIDE_PREFIX, ""),
+            Map.Entry::getValue));
+  }
+
+  /**
+   * Return updated table properties with table properties defaults and 
enforcements set at Catalog level through
+   * catalog properties.
+   *
+   * @return updated table properties with defaults and enforcements set at 
Catalog level
+   */
+  private Map<String, String> updateTableProperties(Map<String, String> 
tableProperties) {

Review comment:
       I find it awkward how this is done outside the existing builder. Why not 
change how properties are built there instead? It would be pretty clean to 
apply the defaults in the builder's constructor, and to add the overrides in 
the `create`/`createTransaction`/`newReplaceTableTransaction` methods.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to