Installation
Install the DuckDB connector:Configuration
DuckDB can run in-memory or connect to a local database file.Local Database File
connection.yaml
The
filename path is relative to your sources directory, not your project root.In-Memory Database
connection.yaml
Configuration Parameters
DuckDB database filename. Use
:memory: for an in-memory database. Path is relative to your sources directory.Initialization Script
You can create aninitialize.sql file in your sources directory to run setup commands before queries execute:
sources/initialize.sql
Features
Type Mapping
DuckDB types are mapped to Evidence types:- Numbers: TINYINT, SMALLINT, INTEGER, BIGINT, HUGEINT, FLOAT, DOUBLE, DECIMAL
- Strings: VARCHAR, STRING, TEXT, TIME
- Dates: DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE
- Booleans: BOOLEAN
Reading External Files
DuckDB can query many file formats directly:queries/parquet_data.sql
queries/csv_data.sql
queries/json_data.sql
S3 and Cloud Storage
With thehttpfs extension, query files from cloud storage:
queries/s3_data.sql
Extensions
DuckDB supports many extensions. Install them in your queries or initialization script:Multi-Statement Queries
The connector supports multi-statement SQL. All statements except the last are executed as setup:queries/with_setup.sql
Example Queries
Query Local Parquet Files
queries/parquet_sales.sql
Join Multiple File Formats
queries/combined_data.sql
Attach Other Databases
queries/multi_database.sql
Performance Tips
Use Columnar Formats
Parquet files offer the best performance for analytical queries:Partition Your Data
Organize files by date or category for better query performance:Persistent Database Benefits
Using a persistent.duckdb file:
- Caches metadata for faster subsequent queries
- Allows indexes and materialized views
- Persists temporary results between sessions
Troubleshooting
File not found errors
File not found errors
- Ensure the
filenamepath is relative to your sources directory - Check that the
.duckdbfile exists at the specified location - For read-only mode, the file must already exist
Extension errors
Extension errors
Extensions must be installed and loaded:
Memory errors
Memory errors
For large datasets, increase memory limit in your queries:
initialize.sql not running
initialize.sql not running
- Ensure the file is named exactly
initialize.sql - Place it in the same directory as your
connection.yaml - Check for SQL syntax errors in the initialization script