load
Generate a runnable DuckDB CREATE TABLE AS statement from CSV profiling — typed columns, safe casts.
Profile a CSV file and generate a ready-to-run DuckDB CREATE TABLE AS SELECT statement. Every column is cast to its detected type using the expression from FineType's taxonomy — no manual type mapping needed.
Usage
finetype load [OPTIONS] --file <FILE>Options
| Flag | Type | Default | Description |
|---|---|---|---|
-f, --file | path | — | Input CSV file (required) |
--table-name | string | derived from filename | Override table name |
-m, --model | path | models/default | Model directory |
--sample-size | integer | 100 | Maximum values to sample per column |
--delimiter | character | auto-detect | CSV delimiter character |
--no-header-hint | flag | — | Disable column name header hints |
--model-type | string | char-cnn | Model type: transformer, char-cnn, tiered |
--sharp-only | flag | — | Disable Sense classifier (Sharpen-only pipeline) |
--limit | integer | 10 | Number of preview rows in trailing SELECT |
--no-normalize-names | flag | — | Disable DuckDB normalize_names (preserve original column names) |
--enum-threshold | integer | 50 | Cardinality threshold for ENUM columns |
Examples
Generate a typed table from CSV
$ finetype load -f contacts.csv-- Generated by FineType (250 types, Sense→Sharpen pipeline)
-- Source: contacts.csv (12 rows, 6 columns)
CREATE TABLE contacts AS
SELECT
CAST(id AS BIGINT) AS id,
name,
email,
strptime(created_at, '%Y-%m-%dT%H:%M:%SZ') AS created_at,
ip_address,
CAST(REGEXP_REPLACE(...) AS DECIMAL(18,2)) AS amount
FROM read_csv('contacts.csv', all_varchar=true);
SELECT * FROM contacts LIMIT 10;Pipe directly into DuckDB
$ finetype load -f contacts.csv | duckdb my.dbThe generated SQL reads the original CSV with all_varchar=true (so nothing is silently coerced), then applies explicit casts. The trailing SELECT * FROM ... LIMIT 10 gives you an immediate preview.
Custom table name
$ finetype load -f data/2024-q1-sales.csv --table-name quarterly_salesBy default the table name is derived from the filename (2024_q1_sales). Use --table-name to override.
What gets generated
The output is a single SQL script containing:
- A
CREATE TABLE AS SELECTthat reads the CSV withall_varchar=true - A
CASTor transform expression for each column, based on its detected type - A trailing
SELECT * FROM <table> LIMIT <n>for preview
Columns that FineType classifies as plain VARCHAR are passed through without a cast. Every other column uses the x-finetype-transform expression from its type schema.
See also
profile— see what types FineType detects before generating SQLschema— inspect the cast expression for any individual type- DuckDB Extension — classify and cast inside DuckDB directly