Spark Lance Integration
Spark reads and writes Lance tables in a SeaweedFS table bucket through the Lance Spark connector, pointed at the SeaweedFS Lance Catalog.
Verified against Spark 3.5.1 and org.lance:lance-spark-bundle-3.5_2.12:0.7.1 by
the integration suite in test/s3tables/catalog_spark_lance/.
Prerequisites
-
SeaweedFS with the Lance Namespace enabled:
weed server -s3 -s3.port.lance=9101 -
A table bucket declared
LANCE, made either from the shell:weed shell > s3tables.bucket -create -name vectors -format LANCE -account 000000000000or at startup, with
weed mini -tableBucket=vectors:LANCE.
Configuration
PySpark
from pyspark.sql import SparkSession
spark = (SparkSession.builder
.appName("SeaweedFS Lance")
.config("spark.jars.packages", "org.lance:lance-spark-bundle-3.5_2.12:0.7.1")
.config("spark.sql.catalog.lance", "org.lance.spark.LanceNamespaceSparkCatalog")
.config("spark.sql.catalog.lance.impl", "rest")
.config("spark.sql.catalog.lance.uri", "http://localhost:9101")
.config("spark.sql.catalog.lance.storage.aws_endpoint", "http://localhost:8333")
.config("spark.sql.catalog.lance.storage.allow_http", "true")
.config("spark.sql.catalog.lance.storage.aws_access_key_id", "…")
.config("spark.sql.catalog.lance.storage.aws_secret_access_key", "…")
.config("spark.sql.catalog.lance.storage.aws_region", "us-east-1")
.getOrCreate())
Pick the bundle that matches your Spark and Scala version — lance-spark-bundle-3.4_2.12,
-3.5_2.12, -3.5_2.13, -4.0_2.13 and others are published under org.lance.
The storage. prefix
Everything under spark.sql.catalog.<name>.storage. is handed to lance as
object_store options, so these are object_store's key names
(aws_endpoint, aws_access_key_id, allow_http) rather than Spark's s3a
ones. Getting this wrong is the usual reason a table lists but will not read.
Credentials belong there because a gateway without STS configured vends an
endpoint and a region but no credentials of its own. With
-s3.iceberg.credentialRole set, the namespace vends real ones and the client
does not need static keys — see SeaweedFS Lance Catalog.
Example SQL
A table bucket is the first level of the namespace path, so a table is addressed
as <catalog>.<bucket>.<namespace>.<table>:
CREATE NAMESPACE IF NOT EXISTS lance.`vectors`.ml;
CREATE TABLE lance.`vectors`.ml.embeddings (
id BIGINT,
title STRING,
vector ARRAY<FLOAT>
) USING lance;
INSERT INTO lance.`vectors`.ml.embeddings VALUES
(1, 'one', array(1.0f, 2.0f, 3.0f)),
(2, 'two', array(2.0f, 3.0f, 4.0f));
SELECT count(*) FROM lance.`vectors`.ml.embeddings;
SELECT id, title FROM lance.`vectors`.ml.embeddings WHERE id >= 2 ORDER BY id;
Backticks around the bucket name are needed when it contains a hyphen.
What to expect
-
CREATE TABLEworks. The connector declares the table through the catalog and writes the data itself; it does not push Arrow data at the server, which is the operation SeaweedFS answersUnsupportedfor. -
SHOW TABLESreturns namespace identifiers, not bare Spark names:SHOW TABLES IN lance.`vectors`.ml -> vectors$ml$embeddings -
Repeated writes are fine. A second
INSERTis the one that fails on a store that cannot order commits; SeaweedFS evaluates Lance's conditional PUT atomically at the object's owner filer, so it does not.
Without Spark
The same tables open in LanceDB Integration, in pylance, or straight off their location with no catalog at all.
See also
Introduction
- Quick Start with weed mini
- Simplest S3 Bucket and User Setup
- Components
- Blob Store Architecture
- Getting Started
- Production Setup
- A typical step‐by‐step example
- Benchmarks
- FAQ
- Applications
API
Configuration
- Replication
- Store file with a Time To Live
- Failover Master Server
- Erasure coding for warm storage
- EC Bitrot Detection
- Server Startup via Systemd
- Environment Variables
Filer
- Filer Setup
- Directories and Files
- File Operations Quick Reference
- Data Structure for Large Files
- Filer Data Encryption
- Filer Commands and Operations
- Filer JWT Use
- TUS Resumable Uploads
Filer Stores
- Filer Cassandra Setup
- Filer Redis Setup
- Super Large Directories
- Path-Specific Filer Store
- Choosing a Filer Store
- Customize Filer Store
Management
Advanced Filer Configurations
- Migrate to Filer Store
- Add New Filer Store
- Filer Store Replication
- Filer Active Active cross cluster continuous synchronization
- Filer as a Key-Large-Value Store
- Path Specific Configuration
- Filer Change Data Capture
- Filer Operation Serialization
FUSE Mount
- Mount on Windows
- FIO benchmark
- fstab and systemd mount
- POSIX Compliance
- Distributed POSIX Locks
- P2P reading in weed mount
- Mount over the Internet
WebDAV
SFTP Server
Cloud Drive
- Cloud Drive Benefits
- Cloud Drive Architecture
- Configure Remote Storage
- Azure Blob Storage Authentication
- Mount Remote Storage
- Cache Remote Storage
- Cloud Drive Quick Setup
- Gateway to Remote Object Storage
AWS S3 API
- Amazon S3 API
- Supported APIs vs Minio
- S3 Lifecycle
- S3 Lifecycle vs Volume TTL
- S3 Conditional Operations
- S3 CORS
- S3 Object Lock and Retention
- S3 Object Versioning
- S3 RenameObject
- S3 API Benchmark
- S3 API FAQ
- S3 Bucket Quota
- S3 Rate Limiting
- S3 API Audit log
- S3 Nginx Proxy
- Docker Compose for S3
S3 Table Bucket
- S3 Table Bucket
- S3 Table Bucket Commands
- S3 Tables Security
- SeaweedFS Iceberg Catalog
- Iceberg REST Catalog API
- Iceberg Table Maintenance
- SeaweedFS Lance Catalog
- Lance Maintenance Worker
Iceberg Integrations
- Spark Iceberg Integration
- Trino Iceberg Integration
- Dremio Iceberg Integration
- DuckDB Iceberg Integration
- Doris Iceberg Integration
- RisingWave Iceberg Integration
- Lakekeeper Iceberg Integration
Lance Integrations
S3 Authentication & IAM
- S3 Configuration - Start Here
- S3 Credentials (
-s3.config) - OIDC Integration (
-s3.iam.config) - Kubernetes ServiceAccount Authentication (IRSA-style)
- S3 Policy Variables
- S3 Policy Conditions
- S3 Bucket Policies
- Amazon IAM API
- AWS IAM CLI
- weed shell - Shell IAM Commands
Server-Side Encryption
S3 Client Tools
- AWS CLI with SeaweedFS
- s3cmd with SeaweedFS
- rclone with SeaweedFS
- restic with SeaweedFS
- nodejs with Seaweed S3
Machine Learning
HDFS
- Hadoop Compatible File System
- run Spark on SeaweedFS
- run HBase on SeaweedFS
- Run Trino on SeaweedFS
- Hadoop Benchmark
- HDFS via S3 connector
Replication and Backup
- Async Replication to another Filer [Deprecated]
- Async Backup
- Async Filer Metadata Backup
- Async Replication to Cloud [Deprecated]
- Kubernetes Backups and Recovery with K8up
Metadata Change Events
Messaging
- Structured Data Lake with SMQ and SQL
- Seaweed Message Queue
- SQL Queries on Message Queue
- SQL Quick Reference
- PostgreSQL-compatible Server weed db
- Pub-Sub to SMQ to SQL
- Kafka to Kafka Gateway to SMQ to SQL
Use Cases
Operations
- System Metrics
- weed shell
- Data Backup
- Deployment to Kubernetes and Minikube
- Helm Chart Recipes
- Deployment with seaweed-up
Rust Volume Server
Advanced
- Large File Handling
- Optimization
- Optimization for Many Small Buckets
- Volume Management
- Tiered Storage
- Cloud Tier
- Cloud Monitoring
- Load Command Line Options from a file
- SRV Service Discovery
- Volume Files Structure
Security
- Security Overview
- Security Configuration
- Cryptography and FIPS Compliance
- Run Blob Storage on Public Internet