Calcite is aiming to implement OpenGIS Simple Features Implementation Specification for SQL, version 1.2.1, a standard implemented by spatial databases such as PostGIS and H2GIS.

We also aim to add optimizer support for spatial indexes and other forms of query optimization.


A spatial database is a database that is optimized for storing and query data that represents objects defined in a geometric space.

Calcite’s support for spatial data includes:

  • A GEOMETRY data type and sub-types including POINT, LINESTRING and POLYGON
  • Spatial functions (prefixed ST_; we have implemented about 35 of the 150 in the OpenGIS specification)

and will at some point also include query rewrites to use spatial indexes.

Enabling spatial support

Though the GEOMETRY data type is built-in, the functions are not enabled by default. You need to add fun=spatial to the JDBC connect string to enable the functions. For example, sqlline:

$ ./sqlline
> !connect jdbc:calcite:fun=spatial "sa" ""
SELECT ST_PointFromText('POINT(-71.064544 42.28787)');
| EXPR$0                        |
| {"x":-71.064544,"y":42.28787} |
1 row selected (0.323 seconds)


Calcite’s OpenGIS implementation uses the Esri geometry API. Thanks for the help we received from their community.

While developing this feature, we made extensive use of the PostGIS documentation and tests, and the H2GIS documentation, and consulted both as reference implementations when the specification wasn’t clear. Thank you to these awesome projects.