Skip to content

Conversation

jagill
Copy link
Contributor

@jagill jagill commented Oct 15, 2025

Description

When a Geometry object reaches the coordinator to be returned to a client, it must be JSON-serialization. We've chosen this representation to be WKT, and previously deserialized it with Esri. As we move to GEOS-based serialization in Prestissimo, which is compatible with JTS deserialization in Java. Change GeometryType.getObjectValue to use JTS instead, which also changes how it handles exceptions.

Also apply the same change to SphericalGeography.

Motivation and Context

It increases compatibility with Prestissimo GEOS-based serialization.

Impact

There should be no user-facing impact.

Test Plan

Existing test TestGeometryStateSerializer covers this.

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

Copy link
Contributor

sourcery-ai bot commented Oct 15, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR replaces the Esri-based geometry deserialization and WKT conversion with a JTS-based implementation (via JtsGeometrySerde and GeometryUtils.wktFromJtsGeometry) in both GeometryType and SphericalGeographyType, streamlining exception handling and improving GEOS serialization compatibility.

Class diagram for updated GeometryType and SphericalGeographyType

classDiagram
    class GeometryType {
        +getObjectValue(properties, block, position)
    }
    class SphericalGeographyType {
        +getObjectValue(properties, block, position)
    }
    class JtsGeometrySerde {
        +deserialize(slice)
    }
    class GeometryUtils {
        +wktFromJtsGeometry(geometry)
    }
    GeometryType --> JtsGeometrySerde : uses
    GeometryType --> GeometryUtils : uses
    SphericalGeographyType --> JtsGeometrySerde : uses
    SphericalGeographyType --> GeometryUtils : uses
Loading

File-Level Changes

Change Details Files
Switch GeometryType.getObjectValue to use JTS serde and utility for WKT conversion
  • Removed EsriGeometrySerde and related exception imports
  • Added JtsGeometrySerde.deserialize and GeometryUtils.wktFromJtsGeometry imports
  • Replaced try-catch with a direct wktFromJtsGeometry(deserialize(slice)) call
presto-main-base/src/main/java/com/facebook/presto/geospatial/type/GeometryType.java
Apply same JTS-based WKT conversion in SphericalGeographyType.getObjectValue
  • Replaced EsriGeometrySerde.deserialize import with JtsGeometrySerde.deserialize
  • Imported GeometryUtils.wktFromJtsGeometry
  • Changed return value from deserialize(slice).asText() to wktFromJtsGeometry(deserialize(slice))
presto-main-base/src/main/java/com/facebook/presto/geospatial/SphericalGeographyType.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@jagill jagill force-pushed the jts-coordinator-deserialization branch from c53666a to 0a65f02 Compare October 15, 2025 19:47
When a Geometry object reaches the coordinator to be returned to a client, it must be JSON-serialization. We've chosen this representation to be WKT, and previously deserialized it with Esri.  As we move to GEOS-based serialization in Prestissimo, which is compatible with JTS deserialization in Java.  Change `GeometryType.getObjectValue` to use JTS instead, which also changes how it handles exceptions.

Also apply the same change to SphericalGeography.
@jagill jagill force-pushed the jts-coordinator-deserialization branch from 0a65f02 to 363f01c Compare October 17, 2025 21:28
@tdcmeehan tdcmeehan changed the title feat(geo): Change Coordinator Geometry conversion to use JTS feat(function): Change Coordinator Geometry conversion to use JTS Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant