davidchaava opened a new pull request, #5427:
URL: https://github.com/apache/calcite/pull/5427

   ## Jira Link
   
   [CALCITE-7946](https://issues.apache.org/jira/browse/CALCITE-7946)
   
   ## Changes Proposed
   
   Add `GEOGRAPHY` as a SQL and relational type distinct from planar 
`GEOMETRY`. This allows Calcite-based engines to preserve geography columns 
through validation and planning without exposing them accidentally to planar 
spatial operations.
   
   The implementation follows the mailing-list discussion and includes two 
structural accessors to demonstrate end-to-end execution, as suggested by Mihai.
   
   ### Type system and SQL support
   
   - Register a distinct `GEOGRAPHY` type name and family, without precision or 
scale.
   - Enable type syntax in `BABEL` and `LENIENT` conformance while keeping 
`GEOGRAPHY` non-reserved.
   - Preserve type identity and nullability through common-type derivation, 
nested types, SQL/Rel conversions, and the tested planner rewrites.
   - Reject concrete casts between `GEOGRAPHY` and `GEOMETRY`, character, or 
binary types.
   - Reject ordering and equality-dependent keys where runtime equality and 
hashing are not supported.
   
   ### Structural accessors and execution
   
   Add explicit signatures for:
   
   - `ST_IsEmpty(GEOGRAPHY)` → `BOOLEAN`
   - `ST_GeometryType(GEOGRAPHY)` → `VARCHAR`
   
   Both functions return SQL NULL for a NULL argument. Empty values return true 
from `ST_IsEmpty` and retain their concrete shape name in `ST_GeometryType`.
   
   SQL type identity remains separate from the runtime shape of a value. For 
local execution, adapters explicitly opt in through `GeographyTable` and supply 
JTS-backed `GeographyValue` objects. The accessors reuse existing JTS 
operations; they perform no geodetic calculations. Existing `GEOMETRY` 
overloads retain their behavior, and geometry-only measurements such as 
`ST_Area` continue to reject geography arguments.
   
   Non-NULL geography literals, parameters, runtime comparisons, and geography 
join keys remain unsupported. This PR does not add geography constructors, 
WKT/WKB conversions, geodetic measurements, independent shape/layout 
constraints, or storage-format integrations.
   
   ## Testing
   
   - Parser and validator tests cover conformance, identifiers, casts, 
nullability, nested types, and invalid operations.
   - Planner tests cover SQL/Rel round trips, selected rewrites, and bounded 
RelJson type-metadata round trips.
   - JDBC tests exercise both accessors in Enumerable and Bindable execution, 
covering all seven supported shapes, empty values, collections containing only 
empty members, and SQL NULL.
   - The accessor validation run passed 169 selected Core tests with no 
failures or skips. Core Checkstyle and the existing `spatial.iq` regression 
also passed.
   
   ## Discussion
   
   - Initial discussion: 
https://lists.apache.org/thread/ykhbf99bggw2ylo4q1nbsyx2244m8cso
   - Implementation approach: 
https://lists.apache.org/thread/mh2w0gxho0d9kkw7pszkvo9mwjyopmlj
   - Feedback on the initial scope and end-to-end functions: 
https://lists.apache.org/thread/vk6s1lq1pdlpwnhn9zgpolt2gsxg6d3m


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to