rdblue commented on code in PR #17022:
URL: https://github.com/apache/iceberg/pull/17022#discussion_r3507182720
##########
core/src/main/java/org/apache/iceberg/MetricsConfig.java:
##########
@@ -100,32 +121,40 @@ public static MetricsConfig forTable(Table table) {
return from(table.properties(), table.schema(), table.sortOrder());
}
- /**
- * Creates a metrics config for a position delete file.
- *
- * @param table an Iceberg table
- * @deprecated This method is deprecated as of version 1.11.0 and will be
removed in 1.12.0.
- * Position deletes that include row data are no longer supported. Use
{@link
- * #forPositionDelete()} instead.
- */
- @Deprecated
- public static MetricsConfig forPositionDelete(Table table) {
- ImmutableMap.Builder<String, MetricsMode> columnModes =
ImmutableMap.builder();
+ public Iterable<Integer> metricsFieldIds() {
+ return idToName.keySet();
+ }
- columnModes.put(MetadataColumns.DELETE_FILE_PATH.name(),
MetricsModes.Full.get());
- columnModes.put(MetadataColumns.DELETE_FILE_POS.name(),
MetricsModes.Full.get());
+ public MetricsMode columnMode(int id) {
+ String name = idToName.get(id);
+ if (name != null) {
+ return columnMode(name);
+ }
- MetricsConfig tableConfig = forTable(table);
+ return defaultMode;
+ }
- MetricsMode defaultMode = tableConfig.defaultMode;
- tableConfig.columnModes.forEach(
- (columnAlias, mode) -> {
- String positionDeleteColumnAlias =
- DOT.join(MetadataColumns.DELETE_FILE_ROW_FIELD_NAME,
columnAlias);
- columnModes.put(positionDeleteColumnAlias, mode);
- });
+ public MetricsMode columnMode(String columnAlias) {
+ return columnModes.getOrDefault(columnAlias, defaultMode);
+ }
+
+ public void validateReferencedColumns(Schema schema) {
+ for (String column : columnModes.keySet()) {
+ Types.NestedField field = schema.findField(column);
+ ValidationException.check(
+ field != null,
+ "Cannot find column %s from table prop %s in schema %s",
+ column,
+ METRICS_MODE_COLUMN_CONF_PREFIX + column,
+ schema);
- return new MetricsConfig(columnModes.build(), defaultMode);
+ ValidationException.check(
Review Comment:
You're right. I'll change this to `column.equals`
--
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]