Skip to content

Parquet: Track avg_value_size_in_bytes for Geo types - #17333

Merged
szehon-ho merged 2 commits into
apache:mainfrom
huan233usc:geo-avg-value-size
Jul 31, 2026
Merged

Parquet: Track avg_value_size_in_bytes for Geo types#17333
szehon-ho merged 2 commits into
apache:mainfrom
huan233usc:geo-avg-value-size

Conversation

@huan233usc

Copy link
Copy Markdown
Contributor

Follow-up to #17313.

This collects the serialized WKB size for geometry and geography values written to Parquet and carries the average over non-null values through FieldMetrics into v4 FieldStats. Both the generic Parquet writer and Spark 4.1 writers populate the metric.

This is based directly on main and is independent of the bounding-box work in #17161.

Tests:

  • ./gradlew :iceberg-core:test --tests org.apache.iceberg.TestValueSizeFieldMetrics --tests org.apache.iceberg.TestFieldStatsStruct
  • ./gradlew :iceberg-parquet:test --tests org.apache.iceberg.parquet.TestParquetValueWriters
  • ./gradlew :iceberg-data:test --tests org.apache.iceberg.parquet.TestParquetMetrics.testMetricsForGeospatialTypes
  • ./gradlew :iceberg-spark:iceberg-spark-4.1_2.13:test --tests org.apache.iceberg.spark.data.TestSparkParquetWriter.testGeospatialWkbRoundTrip
  • ./gradlew :iceberg-core:revapi :iceberg-parquet:revapi

@uros-b uros-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @huan233usc, left just one comment and adding @szehon-ho for further review

}

@Override
public void write(int repetitionLevel, T value) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Spark GeospatialWriter.write() override is a genuinely new code path (calls toWkb(value) then addValueSize(wkb.length)), but no test asserts its avgValueSizeInBytes output; the referenced round-trip test only checks WKB equality/null-ness. The generic writer's metric is directly asserted (TestParquetValueWriters.geospatialValueSizeMetricsExcludeNulls), so the shared accumulation logic is covered, but the Spark writer's size measurement is unexercised. Please consider adding an assertion on the Spark path before merge, also - @szehon-ho please review this PR for Geo, thank you!

Adds TestSparkParquetWriter.testGeospatialAvgValueSizeMetrics, which
exercises the Spark GeospatialWriter.write() path (toWkb + addValueSize)
that the existing WKB round-trip test did not cover, asserting
avgValueSizeInBytes over non-null geometry/geography values. Mirrors the
generic writer's TestParquetValueWriters assertion.

@szehon-ho szehon-ho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File: parquet/.../ParquetMetrics.java (metrics assembly), core/.../FieldStatsStruct.java
Writers correctly accumulate WKB size and FieldStatsStruct.fromFieldMetrics now copies avgValueSizeInBytes, but:

ParquetMetrics.metrics() still builds a Metrics object with no avg field, so DataFile metrics drop it
fromFieldMetrics has no production callers (tests only)
So this does not yet produce avg_value_size_in_bytes in manifests/content stats.

Are we planning to do in follow up?

@huan233usc

huan233usc commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@szehon-ho Yes, this is planned for a separate follow-up PR. This PR is scoped to collecting and plumbing the average WKB value size through FieldMetrics; the Metrics/DataFile and manifest/content-stats integration will be added separately in #17451.

@szehon-ho
szehon-ho merged commit fe30749 into apache:main Jul 31, 2026
36 checks passed
@szehon-ho

Copy link
Copy Markdown
Member

Merged, thanks @huan233usc and @uros-b for additional review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants