[Core] Support Truncate(0) for metrics #11905
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
At Pinterest, we've started utilizing iceberg metrics considerably for offline validation as well as query speedups. Counts are consistently useful for all columns and upper/lowerbound is useful for numeric columns.; however, for struct columns (typically objects with encoded strings), ranges are relatively useless and just cause space overhead with potential driver OOM. There isn't an easy way to specify metrics per data type so wanted to contribute a solution which allows to specify truncate limit as 0 which just causes strings and binaries to be fully truncated.
Changes
Updated checks in Truncate MetricsMode to allow for non-negative rather than strictly positive length. Updated appropriate checks in order to only input into bounds map if non null
Tests
Added appropriate unit tests