Help Center/ AI DataLake/ devg/ Lance Development Guide/ Lance on Aura/ Lance on Aura DDL Syntax Description
Updated on 2026-11-06 GMT+08:00

Lance on Aura DDL Syntax Description

Constraints

Lance tables do not support the creation of partitions and bucket columns.

Creating a Lance Table

When using the CREATE TABLE syntax to create a Lance table, you need to specify STORE AS Lance. For details about the syntax, see CREATE TABLE. The metadata of the created Lance table is stored in LakeFormation, including the table name, table path, current table version, and table parameters. The actual data files of the Lance table are stored in the OBS bucket.

Example:

1
2
3
4
5
6
7
8
9
CREATE TABLE lance_tbl(
col1 int,
col2 array<double>,
col3 bytea
) 
TABLEPROPERTIES (
'enable.blob.col3'='true',
'arrow.fixed-size-list.col2' = '128' 
) STORE AS Lance;

Supported TABLEPROPERTIES parameters:

Table 1

Parameter

Type

Description

enable.blob.col_name

Boolean

Specifies the col_name column as a BLOB column. Only supported for columns of bytea type. For more information about BLOB column support in Lance, see Blob Columns.

arrow.fixed-size-list.col_name

Integer

Specifies that the col_name column is stored as a fixed-length vector using Arrow's FixedSizeList type. The value ranges from 1 to 2147483647. Only supported for one-dimensional arrays of the floating point numbers.

max.rows.per.file

Integer

Specifies the maximum number of rows that can be written to a single file. The value ranges from 1 to 9223372036854775807. The default value is 1048576.

max.bytes.per.file

Integer

Specifies the maximum number of bytes that can be written to a single file. The value ranges from 1 to 9223372036854775807. The default value is 90 GiB.

lance.encoding.compression

String

Specifies the compression algorithm. The value is a string and can be set to zstd, lz4, or fsst. The zstd algorithm supports configuration of the compression level, which ranges from 0 to 22. If no compression level is specified, the default level 3 is used. Compression is disabled by default. For details about the three compression modes, see Compression Modes Supported by Lance.

lance.batch.readahead

Integer

Specifies the number of batches to prefetch. The value ranges from 1 to 9223372036854775807. The default value is 4.

lance.fragment.readahead

Integer

Specifies the number of fragments to prefetch. The value ranges from 1 to 9223372036854775807. The default value is 32.

lance.block.size

Integer

Specifies the minimum number of bytes per I/O request sent to the storage layer. The value ranges from 40 to 34359738368. The default value is 1 MB.

metadata.cache.size

Integer

Specifies the size of the metadata cache, in bytes. The value ranges from 1 to 34359738368. The default value is 1 GiB.

io.buffer.size

Integer

Specifies the size of the I/O buffer, in bytes. The value ranges from 1 to 34359738368. The default value is 2 GiB.

index.cache.size

Integer

Specifies the size of the index cache, in bytes. The value ranges from 1 to 34359738368. The default value is 6 GiB.

index.maximum.nprobes

Integer

Specifies the maximum number of partitions to be selected during index search. The value must be greater than 0. By default, all partitions are searched.

index.minimum.nprobes

Integer

Specifies the minimum number of partitions to be selected during index search. The value must be greater than 0. The default value is 1.

index.refine.factor

Integer

Specifies the candidate result amplification factor for exact-distance-based reranking during index search. The value must be greater than 0. By default, reranking is not performed.

index.explore.factor

Integer

Specifies the capacity of the priority queue during HNSW index search. The value must be greater than 0. The default value is 1.5k.

Description of some table parameters:

  • enable.blob.col_name: To specify a column of bytea type with the column name blob_col1 as a BLOB column, write it as enable.blob.blob_col1 = true.
  • arrow.fixed-size-list.col_name: To define a fixed-length vector column named col2 with a vector dimension of 1024, configure it as arrow.fixed-size-list.col2 = 1024.
  • lance.encoding.compression: Specifies the compression method, which can be zstd, lz4, or fsst, for example, lance.encoding.compression = lz4. If the compression level needs to be configured for zstd, you can write it as lance.encoding.compression = zstd:22.

Truncating a Lance Table

Use the TRUNCATE TABLE syntax to clear data in a table. For details about the syntax, see TRUNCATE.

Example:

1
TRUNCATE TABLE lance_tbl;

Clearing Historical Versions of a Lance Table

You can use the VACUUM TABLE syntax to clear historical versions of a Lance table and data files, transaction files, and index files that are no longer referenced to reclaim the OBS storage space. After operations such as INSERT, UPDATE, DELETE, INSERT OVERWRITE, and ALTER INDEX OPTIMIZE are performed on a Lance table, a new version is generated. The old version and its referenced files are retained and can be cleared using VACUUM TABLE.

The following clearing options are supported:

  • older_than_seconds: An integer ranging from 1 to 31536000. Only the old versions whose generation time exceeds the specified threshold are deleted. If this parameter is omitted, the Lance kernel uses the default value (14 days).
  • delete_rate_limit: An integer ranging from 1 to 2147483647. It indicates the maximum number of deletion operations per second, which is used to prevent OBS traffic limiting from being triggered.

VACUUM TABLE returns a row of clearing statistics, which contains six columns:

Table 2 Returned columns

Column

Type

Description

bytes_removed

bigint

Number of bytes removed during clearing

old_versions

integer

Number of old versions removed

data_files_removed

integer

Number of data files removed

transaction_files_removed

integer

Number of transaction files removed

index_files_removed

integer

Number of index files removed

deletion_files_removed

integer

Number of deletion-marked files that are removed

Example:

Remove old versions generated 2 seconds ago.

1
VACUUM TABLE lance_tbl WITH (older_than_seconds = 2);

Use the default parameters (the Lance kernel deletes old versions generated 14 days ago by default).

1
VACUUM TABLE lance_tbl;

Compacting Lance Table Data

The compaction operation rewrites data in a Lance table, merges multiple small fragments into a larger fragment, and reorganizes the row groups within the fragment based on the configuration. This reduces the number of fragments, lowers metadata overhead, and improves query performance. After multiple INSERT, DELETE, and other operations, a Lance table can accumulate multiple fragments and deletion files. Compaction can merge these small fragments and, based on the configuration, determine whether to materialize deletions of data that has been marked for deletion.

The following table lists the supported compaction options.

Table 3 Parameters

Field

Type

Value Range

Default Value

Description

target_rows_per_fragment

bigint

[1, int32)

1048576 (about 1 million lines)

Specifies the target number of rows per fragment. Compaction rewrites the fragments that meet the criteria to ensure that the new fragments have a row count as close as possible to the value of this parameter. (The number of rows in the new fragment does not have to strictly equal the value of this parameter, and not all fragments with fewer rows than this value will be merged separately.)

max_rows_per_group

bigint

[1, int32)

1024

Specifies the maximum number of rows in a row group (Arrow RecordBatch) within each fragment. If the row count of a fragment exceeds the value, the fragment is divided into multiple row groups.

max_bytes_per_file

bigint

[1, int64)

Default value of write_dataset

Specifies the maximum size (in bytes) of a single .lance file.

materialize_deletions

boolean

true/false

true

Specifies whether to materialize deletions of data that has been marked for deletion during compaction.

  • If this parameter is set to true, the deleted data will be removed from the new fragment.
  • If this parameter is set to false, the deletion files are retained and the original fragments are referenced.

materialize_deletions_threshold

real

[0.0, 1.0]

0.1 (10%)

Specifies the threshold for determining when to materialize deletions during the compaction process. When materialize_deletions is set to true, materialized deletions are performed only for fragments whose deletion ratio exceeds the threshold. Deletion ratio = Number of deleted rows/Total number of rows in the fragment

num_threads

bigint

[0, int32)

Number of CPU cores

Specifies the number of threads used during compaction (controlling the CPU parallelism). If this parameter is set to 0 or not specified, it will automatically use the number of CPU cores on the current server.

batch_size

bigint

[0, int32)

Default value of scanner

Specifies the batch size of data read by the scanner each time (affecting memory usage and processing speed).

defer_index_remap

boolean

true/false

false

Specifies whether to delay index remapping. If this parameter is set to true, compaction does not update the associated indexes immediately. Instead, it records the mapping of fragments, and leaves the index remapping to be completed by subsequent operations. This reduces the execution time of compaction.

max_source_fragments

bigint

[0, int32)

Any

Specifies the maximum number of source fragments that a compaction task can merge. This parameter is used to limit the amount of data that can be rewritten at a time.

Example:

Basic usage:

1
OPTIMIZE lance_table REWRITE DATA;

Specify the number of target fragments.

OPTIMIZE lance_table REWRITE DATA WITH OPTIONS ('target_rows_per_fragment' = '10000');

Perform multiple-parameter configuration.

OPTIMIZE lance_table REWRITE DATA  WITH OPTIONS (    'target_rows_per_fragment' = '10000',    'materialize_deletions' = 'true',    'materialize_deletions_threshold' = '0.2',    'max_source_fragments' = '50');

Dropping a Lance Table

Use the DROP TABLE command to delete a Lance table. This removes both the table metadata and its data. For managed tables, the metadata and data can be restored from the LakeFormation console after deletion. For details about the syntax, see DROP TABLE.

Example:

1
DROP TABLE lance_tbl;

Modifying Table Columns

  • Adding columns:

    Add one or more columns to a specified table. When adding columns, you must specify the column names and data types. New columns are appended to the end of the existing column list.

    ALTER TABLE tbl_name ADD COLUMN col1 typ1, col2 typ2, ....;
  • Dropping columns:

    Remove one or more columns from a specified table. You cannot drop all columns from a table.

    ALTER TABLE tbl_name DROP COLUMNS (col1, col2,...);
  • Renaming columns:

    Rename a specified column. You cannot rename multiple columns at the same time.

    ALTER TABLE tbl_name RENAME COLUMN old_name TO new_name;
  • Changing column types:

    Change the data type of one or more specified columns.

    ALTER TABLE tbl_name ALTER COLUMN a TYPE new_type, b TYPE new_type, ...;

    Currently, only widening conversions (upgrading from lower-precision to higher-precision types) are allowed. Conversions outside the following ranges are not supported:

    • Integer types: From SMALLINT to INT or BIGINT, or from INT to BIGINT.
    • Floating-point types: From FLOAT4 to FLOAT8.
    • Numeric types: From low-precision type to high-precision type. The number of decimal places (scale) cannot be updated.
    • String types: Length increases of VARCHAR or CHAR.

Modifying Table Parameters

  • Adding or modifying parameters:

    Only the following parameters are supported: max.rows.per.file, max.bytes.per.file, and lance.encoding.compression.

    ALTER TABLE tbl_name SET TABLEPROPERTIES('max.rows.per.file'='1024', 'max.bytes.per.file'='2048', 'lance.encoding.compression'='zstd');
  • Removing parameters:

    Only the following parameters are supported: max.rows.per.file, max.bytes.per.file, and lance.encoding.compression.

    ALTER TABLE tbl_name UNSET TABLEPROPERTIES('max.rows.per.file', 'max.bytes.per.file', 'lance.encoding.compression');