Data sources¶
A DataSource object attaches one database or file store as a catalog. The files live in the policy directory.
Example¶
Goal: attach a SQLite file and a DuckDB file, then join them in one query.
# Transactional data in a SQLite file.
apiVersion: sluice.bino.bi/v1alpha1
kind: DataSource
metadata:
name: shop
spec:
type: sqlite
path: ./data/shop.db
# Reference data in a DuckDB file.
apiVersion: sluice.bino.bi/v1alpha1
kind: DataSource
metadata:
name: ref
spec:
type: duckdb_file
path: ./data/ref.duckdb
curl -s http://localhost:8080/v1/query \
-H "X-Api-Key: sl_demo_analyst.supersecret" \
-H "Content-Type: application/json" \
-d '{"sql": "SELECT o.id, o.amount_cents, c.name AS country, c.region FROM shop.main.orders o JOIN ref.main.countries c ON c.code = o.country_code ORDER BY o.id"}'
{
"query_id": "<query-id>",
"columns": ["id", "amount_cents", "country", "region"],
"rows": [
[1, 1999, "United States", "Americas"],
[2, 4599, "Germany", "EMEA"],
[3, 7800, "France", "EMEA"],
[4, 250, "United States", "Americas"],
[5, 32000, "Japan", "APAC"]
],
"row_count": 5,
"truncated": false
}
What happened: metadata.name became the catalog name, so the tables are shop.main.orders and ref.main.countries. Sluice attached both files at start.
limits.disableCrossCatalog: true rejects a query on several catalogs with ACL_REJECTED. See Cross-source joins.
Types¶
type | Reads | Fields | Credentials |
|---|---|---|---|
sqlite | A SQLite file | path | None |
duckdb_file | A DuckDB file | path | None |
postgres | A PostgreSQL database | connection | credentialsRef: the password |
mysql | A MySQL or MariaDB database | connection | credentialsRef: the password |
s3 | Files in an S3 bucket | bucket, region, allowedPaths, endpoint, format | credentialsRef: JSON with key_id, secret, session_token |
http | Files behind HTTP URLs | urls, format | headersRef: JSON object of headers |
motherduck | A MotherDuck database | database | tokenRef: the token |
synthetic | Generated rows from the profile of another data source | synthetic | synthetic.seed: the seed. See Synthetic data |
Fields that end in Ref take a secret reference. The files below are validated, but not tested against a real service.
apiVersion: sluice.bino.bi/v1alpha1
kind: DataSource
metadata:
name: lake
spec:
type: s3
bucket: "ref-data"
region: "us-east-1"
# One view per path: lake.main.countries_csv and lake.main.facts___parquet.
allowedPaths:
- "s3://ref-data/countries.csv"
- "s3://ref-data/facts/*.parquet"
credentialsRef: "secret://env/SLUICE_S3_CREDS"
postgres,mysql: the URL needs a user and a database. The default ports are 5432 and 3306.mysqlalso acceptsmariadb://.s3,http: each path or URL becomes one view in the schemamain. Sluice reads nothing else.s3,http: the extension selects the format:.parquet,.csv,.json,.ndjson,.jsonlor.xlsx.formatsetsparquet,csv,jsonorxlsxfor every path.s3: a path inallowedPathscan hold*or**, except forxlsx.**covers every directory below.endpointnames an S3-compatible store.http: no wildcards. Sluice sends the headers only to the hosts ofurls.
Check the files¶
NAME TYPE FACTORY ERROR
---- ---- ------- -----
web http yes
warehouse motherduck yes
crm mysql yes
pg postgres yes
lake s3 yes
5 checked, 0 failed
The command only reads the files. An invalid file ends it with status 1:
invalid/datasource-postgres.yaml: DataSource/pg: spec.connection: required for postgres/mysql
[exit status 1]
A running server tests every source at start and then every 30 seconds. GET /v1/ready shows the result. See Deployment.
Limits¶
- Sluice attaches databases and files read-only. It reads
s3andhttpdata through views. No setting changes this. - Sluice attaches sources only at start. Restart it after you add or change a
DataSource. - A source that fails a check of its type stops the start. Examples: a missing
sqliteorduckdb_filefile,s3withoutregion,motherduckwithouttokenRef.datasource checkandconfig validatemiss these errors. datasources.failFast: falseskips such a source, andGET /v1/readydoes not list it. A source that Sluice cannot attach still stops the start: a database that is down, or a brokenduckdb_filefile.- The health test checks that a
sqlitefile exists. It does not read the file. A file that is no database stays healthy, and queries on it fail withERR_INTERNAL. - A source that goes away is seen by the next health test. Until then, queries on it can fail with
ERR_INTERNAL.