LanceDB
Connect & Ingest data from / to a LanceDB namespace
LanceDB is a lakehouse and vector database built on the Lance columnar format. Sling connects to a LanceDB namespace: a directory (local or object store) that holds one <table>.lance dataset per table. See https://lancedb.com/ for more details.
The namespace is served through DuckDB's lance extension, which Sling attaches as a DuckDB catalog. The DuckDB SQL dialect, type mapping and merge engine therefore apply, and Sling needs no extra dependency of its own: DuckDB installs and loads the lance extension on first use.
Setup
The following credentials keys are accepted:
path(required) -> The namespace root: the directory holding the.lancedatasets. A local path (/data/lancedb,./lancedb) or an object store URI (s3://bucket/lancedb,gs://bucket/lancedb,az://container/lancedb).instanceis accepted as an alias.schema(optional) -> The default schema to read/write. Default ismain.duckdb_version(optional) -> The CLI version of DuckDB to use. You can also specify the env. variableDUCKDB_VERSION.copy_format(optional v1.6.4+) -> the data format that Sling uses to move data between Sling and DuckDB, for reads and writes. Acceptable values:arrow,csv. Default isarrow. Arrow needs the DuckDBarrowcommunity extension. If DuckDB cannot load this extension (for example, with no internet access), Sling usescsv. If you have issues with arrow, setcsv.copy_method(deprecated) -> usecopy_format.arrow_httpbecomesarrow. All other values becomecsv.max_buffer_size(optional) -> the max buffer size to use when piping data from the DuckDB CLI. Specify this if you have extremely large one-line text values in your dataset. Default is10485760(10MB).max_line_size(optional) -> the max line size (in bytes) to use when piping CSV data into DuckDB. Sling raises this to268435456(256MB) when the data has string, text, json or binary columns, and uses2000000(2MB) otherwise. Specify this only if a single row is larger than 256MB. Applies whencopy_formatiscsv.
Storage Configuration
The lance extension resolves s3:// (plus the s3a:// / s3n:// aliases), gs:// and az:// (plus the abfss:// alias). For S3-compatible services (MinIO, Cloudflare R2, Backblaze B2, ...) use an s3:// path together with s3_endpoint.
For S3/S3-compatible storage:
s3_access_key_id(optional) -> AWS access key IDs3_secret_access_key(optional) -> AWS secret access keys3_session_token(optional) -> AWS session tokens3_region(optional) -> AWS regions3_endpoint(optional) -> S3-compatible endpoint URL (e.g.http://localhost:9000for MinIO)
When no keys are provided, the upstream SDK credential chain is used (environment variables, shared config/credentials profiles, instance metadata).
For Azure Blob / ADLS Storage:
azure_account_name(optional) -> Azure storage account nameazure_account_key(optional) -> Azure storage account keyazure_sas_token(optional) -> Azure SAS token (used when no account key is given)
For Google Cloud Storage:
gcs_key_file(optional) -> Path to a GCS service account key file
Using sling conns
Here are examples of setting a connection named LANCEDB. We must provide the type=lancedb property:
Environment Variable
See here to learn more about the .env.sling file.
Sling Env File YAML
See here to learn more about the sling env.yaml file.
Common Usage Examples
Basic Operations
Data Import/Export
Merge Strategies
All merge strategies are expressed as a single MERGE INTO, which the lance extension supports. The delete ... where exists and update ... from forms cannot be planned by the extension (unsupported DELETE plan: expected 1 child, got 2).
insert
insert rows that are not matched by primary key
update
update matched rows in place
update_insert
update matched rows, insert unmatched rows
delete_insert
update matched rows in place (equivalent end state to delete + insert)
change_capture
apply _sling_synced_op (I, U, D) events, keeping the highest _sling_cdc_seq per primary key
change_capture_soft
same, but marks deletes with _sling_synced_at / _sling_synced_op = 'D' instead of removing the row
Change Capture (CDC)
Replicating a source's change stream into LanceDB uses change_capture, with the events supplied in the _sling_synced_op and _sling_cdc_seq columns:
See Capture Deletes for the delete_missing option, which is also supported for LanceDB targets.
Limitations
Views are not persisted. The lance extension keeps
CREATE VIEWin the session that created it: the view is visible ininformation_schema.tablesfor that session, but nothing is written into the namespace and it is gone after reconnecting. The Lance namespace specification has no view operations either. Use a table (CREATE TABLE ... AS SELECT) when the result must survive a reconnection.Object store schemes. Only
s3://(pluss3a:///s3n://),gs://andaz://(plusabfss://) are resolved. Other schemes (e.g.r2://,gcs://,abfs://) are rejected by the extension; use the matching supported scheme with an explicit endpoint instead.JSON columns are stored as text. The extension writes
JSONcolumns asVARCHAR, so a JSON column round-trips as text.No secondary indexes. Lance datasets have no secondary indexes, so Sling does not create indexes (including unique indexes) on LanceDB targets.
If you are facing issues connecting, give sling assist a try, or reach out to us at support@slingdata.io, on discord or open a Github Issue here.
Last updated
Was this helpful?