Skip to main content

Create Table using CREATE TABLE Command

To create a geospatial table in WherobotsDB, use sedona.sql(...) to run a CREATE TABLE command:
This will create an empty table. Notice that Havasu introduced a new data type geometry to represent geospatial data. Data in columns with geometry type will be loaded as GeometryUDT values in WherobotsDB, user can use any ST_ functions provided by WherobotsDB to manipulate the geospatial data.

Create Table using DataFrame

User can also create a table using a DataFrame. The geometry column in the DataFrame will goes into the GEOMETRY column in the created geospatial table.
Havasu supports a full range of SQL DDL and DML commands which Apache Iceberg supports, such as ALTER TABLE, DROP TABLE, etc.

Writing Geometry Data

Once your table is created, you can insert data using INSERT INTO:
You may have noticed that we use ST_GeomFromText and ST_Point provided by WherobotsDB to construct geometry values and directly inserted them into the Havasu table. Users can also write a DataFrame containing geometry data to a Havasu table:
Or insert data into an existing Havasu table:
Havasu also supports a range of table update operations, such as UPDATE, DELETE, MERGE INTO, etc. Please refer to Apache Iceberg - Spark Writes for details.

Reading Geometry Table

Havasu tables can be queried using SQL SELECT statements:
Or using DataFrame API:
Havasu also supports time travel and inspecting metadata of table. Please refer to Apache Iceberg - Queries for details.

Processing Geometry Data using Spatial SQL

Users can use any ST_ functions provided by WherobotsDB to manipulate geometry data read from Havasu.

Further Reading

For more information, please refer to Geometry Support in Havasu.