Delta Lake tables
Overview
This document describes how to use Apache Gravitino to manage a generic lakehouse catalog using Delta Lake as the underlying table format. Gravitino supports registering and managing metadata for external Delta tables.
Gravitino supports external Delta tables only. This means:
- Register existing Delta tables in Gravitino
- Gravitino manages metadata only (schema, location, properties)
- The physical Delta table data remains independent
- Dropping tables from Gravitino does not delete the underlying Delta data
Table management
Supported operations
For Delta tables in a Generic Lakehouse Catalog, the following table summarizes supported operations:
| Operation | Support Status |
|---|---|
| List | ✅ Full |
| Load | ✅ Full |
| Alter | ❌ Not supported (use Delta Lake APIs directly) |
| Create | ✅ Register external tables only |
| Drop | ✅ Metadata only (data preserved) |
| Purge | ❌ Not supported for external tables |
- External Tables Only: Must set
external=truewhen creating Delta tables - Alter Operations: Not supported; modify tables using Delta Lake APIs or Spark, then update Gravitino metadata if needed
- Purge: Not applicable for external tables; use DROP to remove metadata only
- Partitioning: Identity partitions supported as metadata only; user must ensure consistency with actual Delta table
- Sort Orders: Not supported in CREATE TABLE
- Distributions: Not supported in CREATE TABLE
- Indexes: Not supported in CREATE TABLE
Data type mappings
Delta Lake uses Apache Spark data types. The following table shows type mappings between Gravitino and Delta/Spark:
| Gravitino Type | Delta/Spark Type | Notes |
|---|---|---|
Boolean | BooleanType | |
Byte | ByteType | |
Short | ShortType | |
Integer | IntegerType | |
Long | LongType | |
Float | FloatType | |
Double | DoubleType | |
Decimal(p, s) | DecimalType(p, s) | |
String | StringType | |
Binary | BinaryType | |
Date | DateType | |
Timestamp | TimestampNTZType | No timezone, Spark 3.4+ |
Timestamp_tz | TimestampType | With timezone |
List | ArrayType | |
Map | MapType | |
Struct | StructType |
Properties
Required and optional properties for Delta tables in a Generic Lakehouse Catalog:
| Property | Description | Default | Required |
|---|---|---|---|
format | Table format: must be delta | (none) | Yes |
location | Storage path for the Delta table. Must point to a directory containing Delta Lake metadata (_delta_log). Supports file://, s3://, hdfs://, abfs://, gs://, and other Hadoop-compatible file systems. | (none) | Yes |
external | Must be true for Delta tables. Indicates that Gravitino manages metadata only and will not delete physical data when the table is dropped. | (none) | Yes |
Location Requirement: Must be specified at table level for external Delta table. See Location Resolution.
Operations
Table operations follow standard relational catalog patterns with Delta-specific considerations. See Table Operations for comprehensive documentation.
The following sections provide examples and important details for working with Delta tables.
Register
Register an existing Delta table in Gravitino without moving or modifying the underlying data:
- Shell
- Java
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"name": "customer_orders",
"comment": "Customer orders Delta table",
"columns": [
{
"name": "order_id",
"type": "long",
"comment": "Order identifier",
"nullable": false
},
{
"name": "customer_id",
"type": "long",
"comment": "Customer identifier",
"nullable": false
},
{
"name": "order_date",
"type": "date",
"comment": "Order date",
"nullable": false
},
{
"name": "total_amount",
"type": "decimal(10,2)",
"comment": "Total order amount",
"nullable": true
}
],
"properties": {
"format": "delta",
"external": "true",
"location": "s3://my-bucket/delta-tables/customer_orders"
}
}' http://localhost:8090/api/metalakes/test/catalogs/generic_lakehouse_delta_catalog/schemas/sales/tables
import org.apache.gravitino.Catalog;
import org.apache.gravitino.NameIdentifier;
import org.apache.gravitino.rel.Column;
import org.apache.gravitino.rel.types.Types;
import com.google.common.collect.ImmutableMap;
Catalog catalog = gravitinoClient.loadCatalog("generic_lakehouse_delta_catalog");
TableCatalog tableCatalog = catalog.asTableCatalog();
Map<String, String> tableProperties = ImmutableMap.<String, String>builder()
.put("format", "delta")
.put("external", "true")
.put("location", "s3://my-bucket/delta-tables/customer_orders")
.build();
tableCatalog.createTable(
NameIdentifier.of("sales", "customer_orders"),
new Column[] {
Column.of("order_id", Types.LongType.get(), "Order identifier", false, false, null),
Column.of("customer_id", Types.LongType.get(), "Customer identifier", false, false, null),
Column.of("order_date", Types.DateType.get(), "Order date", false, false, null),
Column.of("total_amount", Types.DecimalType.of(10, 2), "Total order amount", true, false, null)
},
"Customer orders Delta table",
tableProperties,
null, // partitions (optional, identity only)
null, // distributions (not supported)
null, // sortOrders (not supported)
null // indexes (not supported)
);
When registering a Delta table in Gravitino, you must provide the schema (columns) in the CREATE TABLE request. Gravitino stores this schema as metadata but does not validate it against the Delta table's actual schema.
Best Practice: Ensure the schema you provide matches the actual Delta table schema to avoid inconsistencies.
Load
- Shell
- Java
curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/catalogs/generic_lakehouse_delta_catalog/schemas/sales/tables/customer_orders
Table table = tableCatalog.loadTable(
NameIdentifier.of("sales", "customer_orders")
);
System.out.println("Table location: " + table.properties().get("location"));
System.out.println("Columns: " + Arrays.toString(table.columns()));
Drop
Dropping a Delta table from Gravitino removes only the metadata entry. The physical Delta table data remains intact.
- Shell
- Java
curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/test/catalogs/generic_lakehouse_delta_catalog/schemas/sales/tables/customer_orders
boolean dropped = tableCatalog.dropTable(
NameIdentifier.of("sales", "customer_orders")
);
// The Delta table files at the location are NOT deleted
Since Delta tables are external, dropping them from Gravitino: