Infer a schema from sample data
Preview column types and domain candidates from a CSV sample before you commit.
infer_schema reads a CSV sample and returns the columns, Arrow types
(with nullability), and domain candidates - low-cardinality string columns
worth locking down. Always infer before importing so you catch type
surprises while they're cheap to fix.
Infer
infer_schema(csv_content="product_id,name,category,price\nP001,Widget,Electronics,29.99\n...")Returns: row count, column names, Arrow types + nullability, and a list of domain candidates (low-cardinality string columns, with their distinct values). The delimiter is auto-detected for parsing.
Review before committing
Common adjustments after looking at the output:
| Inferred | Usually should be |
|---|---|
Dates as Utf8 | Date32 / Timestamp |
IDs as Int64 (with leading zeros) | Utf8 - preserves 007 |
Boolean-like strings ("yes"/"no") | leave as Utf8, set a fixed domain after import |
Heads up
"001234" becomes 1234 if inferred as Int64. Force
Utf8 for any identifier that can have leading zeros.Then import
Feed the reviewed schema to import_csv - it creates
the table and inserts the rows in one step. Set domains on the flagged candidates
(Govern with domains), then
validate.