RussellSpitzer commented on a change in pull request #3959:
URL: https://github.com/apache/iceberg/pull/3959#discussion_r792007163
##########
File path: core/src/main/java/org/apache/iceberg/MetricsConfig.java
##########
@@ -127,24 +135,39 @@ public static MetricsConfig forPositionDelete(Table
table) {
return new MetricsConfig(columnModes.build(), defaultMode);
}
- private static MetricsConfig from(Map<String, String> props, SortOrder
order) {
+ /**
+ * Generate a MetricsConfig for all columns based on overrides, sortOrder,
and defaultMode.
+ * @param props will be read for metrics overrides
(write.metadata.metrics.column.*) and default
+ * (write.metadata.metrics.default)
+ * @param order sort order columns, will be promoted to truncate(16)
+ * @param defaultMode MetricsConfig default, if not set by user property
+ * @return metrics configuration
+ */
+ private static MetricsConfig from(Map<String, String> props, SortOrder
order, MetricsMode defaultMode) {
Map<String, MetricsMode> columnModes = Maps.newHashMap();
- MetricsMode defaultMode;
- String defaultModeAsString =
props.getOrDefault(DEFAULT_WRITE_METRICS_MODE,
DEFAULT_WRITE_METRICS_MODE_DEFAULT);
- try {
- defaultMode = MetricsModes.fromString(defaultModeAsString);
- } catch (IllegalArgumentException err) {
- // Mode was invalid, log the error and use the default
- LOG.warn("Ignoring invalid default metrics mode: {}",
defaultModeAsString, err);
- defaultMode =
MetricsModes.fromString(DEFAULT_WRITE_METRICS_MODE_DEFAULT);
+
+ // Handle user override of default mode
+ MetricsMode finalDefaultMode;
+ String defaultModeProp = props.get(DEFAULT_WRITE_METRICS_MODE);
+ if (defaultModeProp != null) {
+ try {
+ finalDefaultMode = MetricsModes.fromString(defaultModeProp);
+ } catch (IllegalArgumentException err) {
+ // User override was invalid, log the error and use the default
+ LOG.warn("Ignoring invalid default metrics mode: {}", defaultModeProp,
err);
Review comment:
Yeah I just don't know why we originally had this behavior ... seems odd
to me :shrug:
--
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]