prestodb/presto

ST_Centroid (Java) does not comply with ISO spec

Open

#26,947 opened on Jan 12, 2026

View on GitHub
 (3 comments) (0 reactions) (0 assignees)Java (5,240 forks)batch import
buggood first issue

Repository metrics

Stars
 (15,558 stars)
PR merge metrics
 (Avg merge 34d 14h) (120 merged PRs in 30d)

Description

In the ISO spec, ST_Centroid(empty_geometry) returns NULL, but in the Java code it returns an empty geometry. This is fixed for Velox/native in https://github.com/facebookincubator/velox/pull/15985 , but should also be fixed in Java.

Expected Behavior

ST_Centroid(ST_GeometryFromText('LINESTRING EMPTY')) IS NULL

Current Behavior

ST_IsEmpty(ST_Centroid(ST_GeometryFromText('LINESTRING EMPTY')))

Possible Solution

The ST_Centroid function should check for an empty input geometry and return null.

Steps to Reproduce

SELECT ST_Centroid(ST_GeometryFromText('LINESTRING EMPTY'))

Contributor guide