Enable nested field statistics with inferred metrics limit - #3810
Enable nested field statistics with inferred metrics limit#3810jkasireddy wants to merge 1 commit into
Conversation
|
Hi @Fokko |
| if configured_default_mode is not None: | ||
| # An explicitly configured default applies to all columns. | ||
| self._default_mode = configured_default_mode | ||
| self._inferred_field_ids = None |
There was a problem hiding this comment.
If write.metadata.metrics.default is explicitly set (say, to 'full'), wouldn't we still want write.metadata.metrics.max-inferred-column-defaults to apply? in fact, isn't that when limiting is most important?
There was a problem hiding this comment.
@greenlaw
Good question. I had considered that as well, but I intentionally made an explicitly configured write.metadata.metrics.default bypass write.metadata.metrics.max-inferred-column-defaults to match the current Java MetricsConfig behavior.
In the Java implementation, max-inferred-column-defaults is applied only when there is no explicitly configured default. If write.metadata.metrics.default=full is set, that is treated as an explicit user choice and the mode applies to all columns. Explicit per-column overrides similarly take precedence over the inferred limit.
Since the property is specifically max-inferred-column-defaults, I interpreted the limit as protecting the automatically inferred default behavior rather than overriding an explicit global configuration.
That said, I agree that limiting an explicit full default could also be useful for controlling manifest size. If we want PyIceberg to behave differently here, I’m happy to adjust it, but that would diverge from the current Java behavior. Would you prefer that we preserve Java parity for this PR?
Closes #2699
Rationale for this change
PyIceberg currently downgrades nested primitive fields to
counts, which prevents lower and upper bound statistics from being collected for nested fields.This change enables statistics collection for nested primitive fields and adds support for
write.metadata.metrics.max-inferred-column-defaults, following the behavior of the Iceberg Java implementation.When no explicit default metrics mode is configured, inferred metrics are limited to the configured number of fields. Primitive fields at the current struct level are prioritized before descending into nested fields. Explicit per-column metrics configuration continues to take precedence over the inferred limit.
Are these changes tested?
Yes.
Added regression tests covering:
write.metadata.metrics.max-inferred-column-defaultsLocal test results: