MeridianMERIDIAN

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

FlagTypeDefaultDescription
-f, --filepathInput CSV file (required)
--table-namestringderived from filenameOverride table name
-m, --modelpathmodels/defaultModel directory
--sample-sizeinteger100Maximum values to sample per column
--delimitercharacterauto-detectCSV delimiter character
--no-header-hintflagDisable column name header hints
--model-typestringchar-cnnModel type: transformer, char-cnn, tiered
--sharp-onlyflagDisable Sense classifier (Sharpen-only pipeline)
--limitinteger10Number of preview rows in trailing SELECT
--no-normalize-namesflagDisable DuckDB normalize_names (preserve original column names)
--enum-thresholdinteger50Cardinality 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.db

The 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_sales

By 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:

  1. A CREATE TABLE AS SELECT that reads the CSV with all_varchar=true
  2. A CAST or transform expression for each column, based on its detected type
  3. 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 SQL
  • schema — inspect the cast expression for any individual type
  • DuckDB Extension — classify and cast inside DuckDB directly

On this page