World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
title: "Lance Tables" slug: "/lance-table-support" keywords:
- lakehouse
- lance
- metadata
- generic catalog license: "This software is licensed under the Apache License version 2."
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
Overview
This document describes how to use Apache Gravitino to manage a generic lakehouse catalog using Lance as the underlying table format.
Table Management
Supported Operations
For Lance tables in a Generic Lakehouse Catalog, the following table summarizes supported operations:
| Operation | Support Status |
|---|---|
| List | ✅ Full |
| Load | ✅ Full |
| Alter | ✅ Partial |
| Create | ✅ Full |
| Register | ✅ Full |
| Drop | ✅ Full |
| Purge | ✅ Full |
:::note Feature Limitations
- Partitioning: Not supported
- Sort Orders: Not supported
- Distributions: Not supported
- Indexes: Not supported :::
Data Type Mappings
Lance uses Apache Arrow for table schemas. The following table shows type mappings between Gravitino and Arrow:
| Gravitino Type | Arrow Type |
|---|---|
Struct |
Struct |
Map |
Not supported by Lance |
List |
Array |
Boolean |
Boolean |
Byte |
Int8 |
Short |
Int16 |
Integer |
Int32 |
Long |
Int64 |
Float |
Float |
Double |
Double |
String |
Utf8 |
Binary |
Binary |
Decimal(p, s) |
Decimal(p, s) (128-bit) |
Date |
Date |
Timestamp/Timestamp(6) |
TimestampType withoutZone |
Timestamp(0) |
TimestampType Second withoutZone |
Timestamp(3) |
TimestampType Millisecond withoutZone |
Timestamp(9) |
TimestampType Nanosecond withoutZone |
Timestamp_tz/Timestamp_tz(6) |
TimestampType Microsecond withUtc |
Timestamp_tz(0) |
TimestampType Second withUtc |
Timestamp_tz(3) |
TimestampType Millisecond withUtc |
Timestamp_tz(9) |
TimestampType Nanosecond withUtc |
Time/Time(9) |
Time Nanosecond |
Null |
Null |
Fixed(n) |
Fixed-Size Binary(n) |
Interval_year |
Not supported by Lance |
Interval_day |
Duration(Microsecond) |
External(arrow_field_json_str) |
Any Arrow Field |
External("lance.blob") |
Lance blob |
External("lance.blob.legacy") |
Lance legacy blob |
External Types
For Arrow types not natively mapped in Gravitino, use the External(arrow_field_json_str) type, which accepts a JSON string representation of an Arrow Field.
Requirements:
- JSON must conform to Apache Arrow Field specification
nameattribute is ignored: the column name is authoritative and overrides the name in the JSON, so a column keeps its stored JSON type after a renamenullableattribute must match column nullabilitychildrenarray:- Empty for primitive types
- Contains child field definitions for complex types (Struct, List)
Examples:
| Arrow Type | External Type Definition |
|---|---|
Large Utf8 |
External("{\"name\":\"col_name\",\"nullable\":true,\"type\":{\"name\":\"largeutf8\"},\"children\":[]}") |
Large Binary |
External("{\"name\":\"col_name\",\"nullable\":true,\"type\":{\"name\":\"largebinary\"},\"children\":[]}") |
Large List |
External("{\"name\":\"col_name\",\"nullable\":true,\"type\":{\"name\":\"largelist\"},\"children\":[{\"name\":\"element\",\"nullable\":true,\"type\":{\"name\":\"int\",\"bitWidth\":32,\"isSigned\":true},\"children\":[]}]}") |
Fixed-Size List |
External("{\"name\":\"col_name\",\"nullable\":true,\"type\":{\"name\":\"fixedsizelist\",\"listSize\":10},\"children\":[{\"name\":\"element\",\"nullable\":true,\"type\":{\"name\":\"int\",\"bitWidth\":32,\"isSigned\":true},\"children\":[]}]}") |
Gravitino types cannot carry Arrow field metadata. When loading a Lance table, only Lance blob metadata
is recognized (see Blob Types); other field metadata is ignored. Blob fields nested in a
Struct, List, Map or Union keep the container as a native Gravitino type, for example
List(External("lance.blob")). As with other list columns, the list child is written back as
element, whatever name it had in the Lance dataset (Lance and pyarrow use item).
Blob Types
Lance blob columns use a readable external type instead of Arrow JSON:
| External Type Definition | Arrow Field | Lance File Format Version |
|---|---|---|
External("lance.blob") |
Struct<data: LargeBinary, uri: Utf8> with metadata ARROW:extension:name=lance.blob.v2 |
2.2 or later |
External("lance.blob.legacy") |
LargeBinary with metadata lance-encoding:blob=true |
2.1 or earlier |
Use lance.blob for new tables. lance.blob.legacy is only for datasets that already use Lance's
legacy blob encoding.
When Gravitino creates a Lance dataset with blob columns, it picks the Lance file format version for
them: 2.2 for lance.blob and 2.1 for lance.blob.legacy. A table cannot have both. Adding a blob
column to an existing dataset fails with a clear error if the dataset's file format version does not
support it.
A table created without blob columns uses Lance's own default file format version, 2.2 as of
lance-core 12.0.0, and there is no property to override it. Such a table accepts a later
lance.blob column but rejects lance.blob.legacy; tables created by earlier releases, whose
Lance default was below 2.2, behave the other way round and keep their stored version.
Any Lance client can read such a table. Writing to it needs a client that writes at the
dataset's own file format version rather than at its own default. lance-spark 0.2.0 does not: it
passes no data storage version to Lance, so every write goes out at lance-core 2.0.0's default of
2.0 and the commit is refused with All data files must have the same version. Detected both 2.2 and 2.0 — or, while the dataset is still empty, The operation added files with version 2.0. However, the data storage version is 2.2. This is not specific to version 2.2: earlier Gravitino
releases pinned the same tables at 2.1 and refused the same write. lance-spark 0.4.0 and later
read the dataset's version before writing and are unaffected, as are tables created through a
connector — that path uses DeclareTable, and the connector writes the dataset at its own version.
Only the blob marker is recognized. Other blob metadata, such as
lance-encoding:blob-dedicated-size-threshold, is not shown in the Gravitino type, and columns created
through Gravitino use Lance's defaults. A blob field in any other layout, for example a blob v2 struct
with the optional position and size fields or a legacy blob stored as Binary, is returned as
External(arrow_field_json_str) so that it keeps its exact definition.
:::note
Column types stored by an earlier Gravitino version are rewritten only when the table schema is
refreshed from the Lance dataset, which depends on the catalog's
schema refresh mode. The default DECLARED_AND_EMPTY mode never refreshes a
table that is neither declared nor empty, so such a table keeps its stored types even after the
dataset version changes; set lance.schema-refresh-mode to VERSION_CHECK to refresh it on the next
version change. Until a refresh happens, blob v2 columns still appear as a plain Struct, and legacy
blob columns stored as External(arrow_field_json_str) keep that form instead of
External("lance.blob.legacy").
:::
Ownership with EXIST_OK
You can use lance.creation-mode=EXIST_OK with the Gravitino table API and with Lance REST.
- If the table already exists, Gravitino returns it and keeps its owner. This is also true when the table has no owner.
- If another request is still creating the table, the
EXIST_OKrequest does not set the owner. The creator sets it. - If the request creates a new table, the caller becomes the owner when authorization is enabled.
Gravitino creates the table and sets the owner in two separate steps. If the table is created but
setting the owner fails, a repeated EXIST_OK request does not fix the owner. Fix the cause, then
set the owner explicitly.
Table Properties
Required and optional properties for tables in a Generic Lakehouse Catalog:
| Property | Description | Default | Required |
|---|---|---|---|
format |
Table format: lance, only lance is fully supported. |
(none) | Yes |
location |
Storage path for table metadata and data, Lance supports: S3, GCS, OSS, AZ, File, Memory and file-object-store. | (none) | Conditional* |
external |
Whether the data directory is an external location. If it's true, dropping a table will only remove metadata in Gravitino and will not delete the data directory, and purge is rejected unless the catalog enables lance.allow-external-table-purge. For a non-external table, dropping will drop both. |
false | No |
lance.creation-mode |
Create mode: for create table, it can be CREATE, EXIST_OK or OVERWRITE. and it should be CREATE or OVERWRITE for registering tables |
CREATE |
No |
lance.register |
Whether it is a register table operation. If true, register an existing, readable Lance dataset without creating data. A missing dataset or plain directory is rejected. Registered tables are external. If false, create a dataset. |
false | No |
lance.storage.xxxx |
Any additional storage-specific properties required by Lance format (e.g., S3 credentials, HDFS configs). Replace xxxx with actual property names. For example, we can use lance.storage.aws_access_key_id to set S3 aws_access_key_id when using a S3 location, for detail, refer to https://lancedb.com/docs/storage/integrations/ |
(none) | No |
CREATE: Create a new table, fail if the table already exists.EXIST_OK: Create a new table if it does not exist, otherwise do nothing.OVERWRITE: For creation (lance.register=false), purge the existing table and its dataset before creating a replacement. An existing external table requires the catalog to enablelance.allow-external-table-purge; otherwise the original metadata and data are retained. For registration (lance.register=true), validate the replacement dataset first and replace only external-table metadata, retaining the old dataset. Registration overwrite of a managed table is rejected; explicitly dropping or purging a managed table deletes its data.
Registration validation checks dataset existence and readability, not an operator-defined storage scope or authorization to purge external data.
Format boundary
The Generic Catalog is format-agnostic for its general table APIs, but a Lance table operation must
target an entity whose format property is lance (case-insensitive). Lance REST direct
operations such as describe, drop, deregister, and alter reject a known non-Lance entity with
HTTP 400 INVALID_INPUT; tableExists presents it as absent. These checks preserve the existing
metadata and location.
For create requests dispatched to the Lance table delegator, an existing non-Lance entity remains
a normal name conflict for CREATE (409). EXIST_OK, create OVERWRITE, and register
OVERWRITE are rejected with IllegalArgumentException by the direct Gravitino API, which is
returned as HTTP 400 by the Lance REST service. In particular, overwrite validation happens
before metadata removal or a Lance dataset delete. Generic Catalog ListTables behavior is
unchanged; it continues to list all formats. Format-specific listing is a separate follow-up
concern.
Location Requirement: Must be specified at catalog, schema, or table level. See Location Resolution.
Also set additional properties specific to your lakehouse format or custom requirements.
Schema Refresh
For Lance tables, Gravitino stores table columns in its metadata store. Some Lance writers can also update the dataset directly at the Lance location. To keep Gravitino metadata in sync, the Generic Lakehouse catalog supports catalog-level schema refresh modes:
| Mode | Behavior |
|---|---|
DECLARED_AND_EMPTY |
Default. Refreshes schema from the Lance dataset for two cases: (1) declared tables (lance.declared=true) whose schema has not yet been written to Gravitino; (2) tables whose Gravitino column list is empty, for example tables registered before their schema was captured. |
VERSION_CHECK |
Opens the Lance dataset on every loadTable, compares the dataset version with lance.version, and refreshes columns when the version has changed. |
Use VERSION_CHECK only when tables may be modified directly through the Lance path outside
Gravitino. It adds a dataset version check to every loadTable call.
:::note Zero-column Lance dataset
If a Lance dataset genuinely has no columns, DECLARED_AND_EMPTY mode records the checked dataset
version (lance.version) on the first loadTable call. Subsequent loads skip opening the dataset
as long as the stored version is unchanged. Before recording a new version, Lance table
alterations recheck an empty stored schema and abort if it cannot be loaded, so incomplete column
metadata is not associated with the latest dataset version.
:::
Table Operations
Table operations follow standard relational catalog patterns. See Table Operations for comprehensive documentation.
The following sections provide examples and important details for working with Lance tables.
Add a Column
Lance tables support adding nullable, top-level columns through the Gravitino table API. New
columns are appended to the schema, and Lance backfills existing rows with NULL.
curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"updates": [
{
"@type": "addColumn",
"fieldName": ["new_column"],
"type": "string",
"comment": "New nullable column",
"position": "default",
"nullable": true,
"autoIncrement": false
}
]
}' http://localhost:8090/api/metalakes/test/catalogs/generic_lakehouse_lance_catalog/schemas/schema/tables/lance_table
The following add-column options are not supported:
- Nested columns
- Non-nullable columns
FIRSTorAFTERcolumn positions- Default values
- Auto-increment columns
:::note
This operation is available through the Gravitino table API and Java client. The Lance REST
/add_columns endpoint is not supported yet.
:::
Create a Lance Table
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"name": "lance_table",
"comment": "Example Lance table",
"columns": [
{
"name": "id",
"type": "integer",
"comment": "Primary identifier",
"nullable": false
}
],
"properties": {
"format": "lance",
"location": "/tmp/lance_catalog/schema/lance_table"
}
}' http://localhost:8090/api/metalakes/test/catalogs/generic_lakehouse_lance_catalog/schemas/schema/tables
Catalog catalog = gravitinoClient.loadCatalog("generic_lakehouse_lance_catalog");
TableCatalog tableCatalog = catalog.asTableCatalog();
Map<String, String> tableProperties = ImmutableMap.<String, String>builder()
.put("format", "lance")
.put("location", "/tmp/lance_catalog/schema/example_table")
.build();
tableCatalog.createTable(
NameIdentifier.of("schema", "lance_table"),
new Column[] {
Column.of("id", Types.IntegerType.get(), "Primary identifier",
true, false, null)
},
"Example Lance table",
tableProperties,
null, // partitions
null, // distributions
null, // sortOrders
null // indexes
);
Register External Tables
Register existing Lance tables without moving or copying data. A table with lance.register=true
is always external, including when the request omits external or sets it to false. Dropping it
through the Gravitino table API removes only the metadata. Explicit purgeTable and Lance REST
drop are rejected by default, preserving metadata and data. A catalog administrator may set
lance.allow-external-table-purge=true to allow both to be deleted. This setting is read only from
catalog properties; a table property cannot enable it. Use Lance REST deregister to remove
metadata while preserving data. The opt-in does not validate location ownership.
Existing registrations with a missing or false stored external flag receive the same protection
when dropped or deregistered. Their stored properties are not automatically migrated.
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"name": "register_lance_table",
"comment": "Registered existing Lance table",
"columns": [],
"properties": {
"format": "lance",
"lance.register": "true",
"location": "/tmp/lance_catalog/schema/existing_lance_table"
}
}' http://localhost:8090/api/metalakes/test/catalogs/generic_lakehouse_lance_catalog/schemas/schema/tables
Catalog catalog = gravitinoClient.loadCatalog("generic_lakehouse_lance_catalog");
TableCatalog tableCatalog = catalog.asTableCatalog();
Map<String, String> registerProperties = ImmutableMap.<String, String>builder()
.put("format", "lance")
.put("lance.register", "true")
.put("location", "/tmp/lance_catalog/schema/existing_lance_table")
.build();
tableCatalog.createTable(
NameIdentifier.of("schema", "register_lance_table"),
new Column[] {}, // Schema auto-detected from existing table
"Registered existing Lance table",
registerProperties,
null, null, null, null
);
:::tip Registration vs Creation
Registration (
lance.register: true):- Requires an existing, readable Lance dataset; missing datasets and plain directories are rejected
- Schema automatically detected from Lance metadata
- Useful for importing existing datasets
Creation (default):
- Creates new Lance table from scratch
- Requires column schema definition
- Initializes new Lance dataset files :::
Advanced Topics
Troubleshooting
Common Issues
Issue: "Location not specified" error
Solution: Ensure at least one level (catalog/schema/table) specifies the location property
Issue: Permission denied errors
Solution: Check file system permissions and credentials for the storage backend
Issue: Table not found after registration
Solution: Verify the location path points to a valid Lance dataset directory
Migration Guide
Migrate Existing Lance Tables
- Inventory: List all existing Lance table locations
- Create Catalog: Create Generic Lakehouse catalog pointing to root location
- Register Tables: Use register operation for each table
- Verify: Confirm all tables are accessible through Gravitino
- Update Clients: Point applications to Gravitino metadata instead of direct Lance access
Example Migration Script:
# List of existing Lance tables to register
tables_to_migrate=(
"sales orders /data/sales/orders"
"sales customers /data/sales/customers"
"inventory products /data/inventory/products"
)
# Register each table
for entry in "${tables_to_migrate[@]}"; do
read -r schema table location <<< "$entry"
echo ${schema}
echo ${table}
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d "{
\"name\": \"${table}\",
\"comment\": \"Registered existing Lance table\",
\"columns\": [],
\"properties\": {
\"format\": \"lance\",
\"lance.register\": \"true\",
\"location\": \"${location}\"
}
}" http://localhost:8090/api/metalakes/test/catalogs/generic_lakehouse_lance_catalog/schemas/$schema/tables
echo "Registered ${schema}.${table}"
done
Other table operations (load, alter, drop, truncate) follow standard relational catalog patterns. See Table Operations for details.
Lance Table with MinIO
To use Lance tables stored in MinIO with Gravitino, configure the MinIO storage backend once on the Lance catalog. Gravitino will then return those storage options to Lance clients and Spark does not need to repeat them.
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" \
-d '{
"name": "lance_catalog",
"type": "RELATIONAL",
"provider": "lakehouse-generic",
"comment": "catalog for Lance tables on MinIO",
"properties": {
"location": "s3://bucket1/lance",
"lance.storage.endpoint": "http://minio:9000",
"lance.storage.access_key_id": "ak",
"lance.storage.secret_access_key": "sk",
"lance.storage.allow_http": "true",
"lance.storage.region": "us-east-1"
}
}' http://localhost:8090/api/metalakes/test/catalogs
curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"name": "lance_orders",
"comment": "Order table stored in MinIO",
"columns": [
{
"name": "id",
"type": "integer",
"comment": "Primary identifier",
"nullable": false
}
],
"properties": {
"format": "lance",
"location": "s3://bucket1/lance_orders"
}
}' http://localhost:8090/api/metalakes/test/catalogs/lance_catalog/schemas/sales/tables
A table can add lance.storage.* table properties for keys that the catalog does not set. If the
catalog sets a key, the catalog value is used, and the table value is ignored. This prevents a table
creator from sending the catalog credentials to another endpoint. Put tables that need a different
endpoint or credentials in a separate catalog.