rdblue commented on a change in pull request #4011:
URL: https://github.com/apache/iceberg/pull/4011#discussion_r795267343
##########
File path: api/src/main/java/org/apache/iceberg/catalog/Catalog.java
##########
@@ -388,6 +392,59 @@ default TableBuilder buildTable(TableIdentifier
identifier, Schema schema) {
default void initialize(String name, Map<String, String> properties) {
}
+ /**
+ * Get catalog properties.
+ *
+ * @return catalog properties
+ */
+ Map<String, String> properties();
+
+ /**
+ * Get default table properties set at Catalog level through catalog
properties.
+ *
+ * @return default table properties specified in catalog properties
+ */
+ default Map<String, String> tableCreateDefaultProperties() {
+ String tableCreateDefaultPrefix = "table.create.default.";
+ Map<String, String> props = properties() == null ? Collections.emptyMap()
: properties();
+
+ return props.entrySet().stream()
+ .filter(e ->
e.getKey().toLowerCase(Locale.ROOT).startsWith(tableCreateDefaultPrefix))
+ .collect(Collectors.toMap(e ->
e.getKey().replace(tableCreateDefaultPrefix, ""),
+ Map.Entry::getValue));
+ }
+
+ /**
+ * Get table properties that are enforced at Catalog level through catalog
properties.
+ *
+ * @return default table properties enforced through catalog properties
+ */
+ default Map<String, String> tableCreateEnforcedProperties() {
+ String tableCreateEnforcedPrefix = "table.create.enforced.";
+ Map<String, String> props = properties() == null ? Collections.emptyMap()
: properties();
+
+ return props.entrySet().stream()
+ .filter(e ->
e.getKey().toLowerCase(Locale.ROOT).startsWith(tableCreateEnforcedPrefix))
+ .collect(Collectors.toMap(e ->
e.getKey().replace(tableCreateEnforcedPrefix, ""),
+ 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
+ */
+ default Map<String, String> overrideTableProperties(Map<String, String>
tableProperties) {
+ Map<String, String> props = tableProperties == null ?
Collections.emptyMap() : tableProperties;
+
+ return Stream.concat(Stream.concat(
+ tableCreateDefaultProperties().entrySet().stream(),
+ props.entrySet().stream()),
Review comment:
This mixes indentation for semantic levels. See
https://github.com/apache/iceberg/blob/master/CONTRIBUTING.md#line-breaks
--
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]