kbendick commented on a change in pull request #4011:
URL: https://github.com/apache/iceberg/pull/4011#discussion_r799872564
##########
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:
Nit: Would it be possible to name this something that makes it a bit
more obvious what this function does instead of the verb `update`?
Maybe `combineCatalogDerivedTablePropertiesWith`? Kind of long, but the
current usages like the following are now that clear to me when read.
```java
return buildTable(identifier, schema)
.withPartitionSpec(spec)
.withLocation(location)
.withProperties(updateTableProperties(properties))
.create();
```
If it were the following, the long name might be justified to as it is more
readable (to me at least).
```
return buildTable(identifier, schema)
.withPartitionSpec(spec)
.withLocation(location)
.withProperties(combinCatalogTablePropertiesWith(properties))
.create();
```
I'm open to other names and would love to hear other people's opinion. This
is by no means a blocker (especially as the method is `private` anyway).
--
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]