{"id":47938399,"url":"https://github.com/lancedb/lancedb-duckdb-demo","last_synced_at":"2026-04-04T07:55:25.842Z","repository":{"id":348745714,"uuid":"1199486205","full_name":"lancedb/lancedb-duckdb-demo","owner":"lancedb","description":"Using the Lance extension in DuckDB for querying, joining and materializing on tables in either system","archived":false,"fork":false,"pushed_at":"2026-04-02T17:13:03.000Z","size":80,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-04T07:55:21.634Z","etag":null,"topics":["agent","date-engineering","duckdb","etl","lance","lancedb","retrieval","search"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lancedb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-02T11:55:11.000Z","updated_at":"2026-04-02T17:14:24.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lancedb/lancedb-duckdb-demo","commit_stats":null,"previous_names":["lancedb/lancedb-duckdb-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lancedb/lancedb-duckdb-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancedb%2Flancedb-duckdb-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancedb%2Flancedb-duckdb-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancedb%2Flancedb-duckdb-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancedb%2Flancedb-duckdb-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lancedb","download_url":"https://codeload.github.com/lancedb/lancedb-duckdb-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lancedb%2Flancedb-duckdb-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31392188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T04:26:24.776Z","status":"ssl_error","status_checked_at":"2026-04-04T04:23:34.147Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent","date-engineering","duckdb","etl","lance","lancedb","retrieval","search"],"created_at":"2026-04-04T07:55:25.316Z","updated_at":"2026-04-04T07:55:25.834Z","avatar_url":"https://github.com/lancedb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LanceDB ｘ DuckDB Demo\n\nA hands-on example showing how LanceDB and DuckDB work together on multimodal data. The repo ingests the [Amazon Berkeley Objects](https://amazon-berkeley-objects.s3.amazonaws.com/index.html) (ABO) dataset into a LanceDB catalog with CLIP image embeddings and text embeddings, then uses DuckDB with the [Lance extension](https://github.com/lance-format/lance-duckdb) to query, join, and materialize results via SQL.\n\nThe LanceDB `products` table stores product metadata, image paths, a CLIP multimodal vector (`multimodal_vec`), and a text-semantic vector (`text_vec`). DuckDB attaches the Lance directory as a namespace and runs SQL directly on top of it -- vector search, joins to local DuckDB tables, and aggregations to answer questions about the data.\n\n## Setup\n\nRequires Python 3.12+.\n\n```bash\n# Sync dependencies from pyproject.toml\nuv sync\n# Add dependencies as needed\nuv add ...\n```\n\n### Download the ABO dataset\n\nDownload the listings metadata and small images from the [ABO dataset page](https://amazon-berkeley-objects.s3.amazonaws.com/index.html) and extract them into `data/`:\n\nAfter extracting, the layout should look like:\n\n```bash\ndata/\n  abo-listings/listings/metadata/   # listings_*.json.gz files\n  abo-images-small/images/\n    metadata/images.csv.gz          # image metadata\n    small/                          # downscaled image files\n```\n\n## Usage\n\n### Ingest products into LanceDB\n\nEmbeddings are computed and written to LanceDB in batches, so progress is saved incrementally.\n\n```bash\n# Full ingestion (~145K products)\nuv run python ingest.py\n\n# Smoke test with a subset\nuv run python ingest.py --limit 200\n\n# Larger batches (default is 32)\nuv run python ingest.py --batch-size 128\n```\n\nThe output LanceDB directory is `./abo-products-lance` by default (override with `--output-root`).\n\n### Text-semantic search\n\nSearch the catalog by text using the `text_vec` embedding column:\n\n```bash\nuv run python text_search.py\n```\n\nThis encodes the text query with the `intfloat/multilingual-e5-base` multilingual embedding model and runs a top-k vector search over the Lance table via DuckDB.\n\n### Create a DuckDB sales table\n\nBefore running the image search, generate a local `sales.duckdb` file with synthetic sales rows linked to shoe products in the Lance catalog:\n\n```bash\nuv run python create_duckdb.py\n```\n\nThis reads shoe `item_id`s from the Lance table and creates a `sales` table with 100 randomly assigned purchases. The image search script joins against this table.\n\n### Image-semantic search with sales join\n\nSearch by visual concept using the CLIP `multimodal_vec` column and join results to the `sales` table:\n\n```bash\nuv run python image_search.py\n```\n\nThis encodes the query `\"beige shoes\"` with CLIP, retrieves the nearest products, and joins them to `sales.duckdb`.\n\n### Query with the DuckDB CLI\n\nYou can also query the Lance table directly from the DuckDB CLI:\n\n```bash\nduckdb\n```\n\n```sql\nINSTALL lance;\nLOAD lance;\nATTACH './abo-products-lance' AS abo (TYPE LANCE);\n\nSELECT item_id, title, brand, product_type\nFROM abo.main.products\nLIMIT 10;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancedb%2Flancedb-duckdb-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flancedb%2Flancedb-duckdb-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flancedb%2Flancedb-duckdb-demo/lists"}