Skip to content

feat: support geometry and geography types - #2653

Closed
wirybeaver wants to merge 2 commits into
apache:mainfrom
wirybeaver:support-geometry-geography-types
Closed

feat: support geometry and geography types#2653
wirybeaver wants to merge 2 commits into
apache:mainfrom
wirybeaver:support-geometry-geography-types

Conversation

@wirybeaver

@wirybeaver wirybeaver commented Jun 16, 2026

Copy link
Copy Markdown

Summary

This draft PR adds Iceberg Geometry/Geography primitive type support by reusing arrow-rs/parquet-geospatial support instead of introducing a local geospatial model.

  • Adds GeometryType and GeographyType, using parquet_geospatial::WkbEdges for geography edge interpolation algorithms.
  • Converts Geometry/Geography to Arrow WKB extension metadata and enables Parquet geospatial logical type writing.
  • Maps Avro, Glue, and HMS representations to bytes/binary.
  • Rejects non-null JSON defaults, blocks unsupported partition transforms, and skips byte min/max statistics for spatial values.

Related issues

Related to #2411 and #1884.

@paleolimbot paleolimbot 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.

Very cool!

I will take a closer look tomorrow, but note that there is a PR into parquet-geospatial to fix the translation between GeoArrow and Parquet types, which mostly was incorrect for Geography but there were a few subtle issues otherwise. There are a number of test cases parameterized nicely at the bottom that you can reuse here. apache/arrow-rs#10065

Just because I happen to be reviewing it, it may also be useful to reference the initial Go PR which has a similar scope: apache/iceberg-go#1138

@wirybeaver

Copy link
Copy Markdown
Author

@paleolimbot Thanks for pointing out those edge cases. I will take a closer look.

@huan233usc huan233usc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Really nice to see this — the type model, Parquet geometry/geography logical types, and especially skipping byte min/max for spatial columns all line up with the spec. A couple of design-alignment points inline.

Comment thread crates/iceberg/src/spec/datatypes.rs Outdated

impl GeographyType {
/// Creates a geography type with an optional coordinate reference system and edge interpolation algorithm.
pub fn new(crs: Option<String>, algorithm: WkbEdges) -> Result<Self> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The public iceberg::spec API exposes parquet_geospatial::WkbEdges (GeographyType::new/algorithm()), coupling the type layer to the parquet-geospatial crate. The set of edge algorithms is defined by the spec itself (edge-interpolation-algorithm) — could we define an Iceberg-owned enum mirroring the spec and convert to WkbEdges only at the Parquet boundary, keeping the type layer format-agnostic?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in 3c8a92e. GeographyType now uses an Iceberg-owned EdgeInterpolationAlgorithm, and Arrow schema conversion maps to/from parquet_geospatial::WkbEdges only at the WKB extension metadata boundary.

PrimitiveType::Fixed(_)
| PrimitiveType::Binary
| PrimitiveType::Geometry(_)
| PrimitiveType::Geography(_) => PrimitiveLiteral::Binary(Vec::from(bytes)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The single-value path decodes geo bytes as opaque WKB. Per the spec, geo bounds are a single point encoded as x:y[:z][:m] little-endian f64s, not WKB (bound-serialization, bounds-for-geometry-and-geography). Both implementations skip spatial bounds today so it's latent, but worth agreeing the bound codec follows the spec point encoding so they don't diverge later.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed. This PR still omits spatial lower/upper bounds from the Parquet writer, so it does not claim WKB-based bound support. If we add spatial bounds later, the bound codec should use the spec point encoding (x:y[:z][:m] as little-endian f64 values), not WKB.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.

@github-actions github-actions Bot added the stale label Jul 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@github-actions github-actions Bot closed this Jul 31, 2026
@wirybeaver

Copy link
Copy Markdown
Author

Reopening because this PR was closed accidentally.

@wirybeaver

Copy link
Copy Markdown
Author

@paleolimbot This PR was closed by the stale bot. GitHub does not allow me to reopen it (viewerCanReopen: false). Could you please reopen it? The branch is still active and I am continuing the work. Thank you.

@paleolimbot

Copy link
Copy Markdown
Member

I'm not a maintainer here so I can't. You can probably make a new PR (or if that doesn't work, rename the branch and open a new PR). I'm still happy to review but this fell off my radar. If you find a way to reopen with your latest work I will take a look!

@wirybeaver

Copy link
Copy Markdown
Author

@paleolimbot I created a new PR #2933 Feel free to take a review

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants