Skip to main content
A geometry column created as geometry, with no CRS in parentheses, does not check the Spatial Reference Identifier (SRID) of the values written to it, and an Apache Iceberg engine outside Wherobots reads it as a binary column. A column created as geometry(<srid>) rejects values in the wrong Coordinate Reference System (CRS) and is readable as geometry by other engines that support geospatial types. See Geometry Support in Havasu for how those columns work.
Tables that have not been upgraded keep working. Reads, spatial filter push-down, and every ST_ function behave the same on them.
There is no in-place conversion. ALTER TABLE ... ALTER COLUMN cannot add a CRS to an existing geometry column:
Upgrading is create-and-copy.
org_catalog throughout this page is an example catalog name. Replace it with the name of the catalog you are writing to.

Upgrade a table

Check whether the table needs upgrading

DESCRIBE TABLE shows geometry for both kinds of column, so it does not tell them apart.

Check which SRIDs the column holds

A column with no declared CRS can hold more than one SRID; a geometry(<srid>) column cannot. What comes back decides both the CRS you declare in the next step and the expression you copy with in the step after it:ST_SetSRID relabels without touching the coordinates. Applying it to metre coordinates declares them as longitude and latitude, which puts the data in the wrong place. SRID 0 rows carry no CRS, so ST_Transform has nothing to reproject them from and fails on them: look at their coordinates to find out which CRS they are in before you label them.

Create the new table

Use the CRS from the previous step. This example assumes longitude and latitude.
The SHOW CREATE TABLE output from step 1 shows the partitioning and table properties of the source table. Carry them over to the new statement.

Copy the rows

When every row is SRID 4326 or 0 and the coordinates are longitude and latitude:
When the column mixes SRID 0 rows that are longitude and latitude with rows in other SRIDs, reproject the rows that carry an SRID and label all of them:

Compare the tables and switch over

When the counts match, point your queries and jobs at the new table. If the source table was clustered, run CREATE SPATIAL INDEX on the new table as described in Cluster by Geospatial Fields for Faster Queries. Drop the source table once nothing reads from it.
A copied value disagrees with the CRS of the new column, which means the copy expression does not cover every SRID the source holds. Go back to the SRID check and pick the expression for that result.

Geometry Support in Havasu

Creating, writing, updating, and querying geometry tables.

Cluster by Geospatial Fields

Spatial filter push-down and the full CREATE SPATIAL INDEX syntax.