infer_schema
Sample a CSV, Excel, JSON, or JSONL file to infer column types and generate a draft V2 schema for a new or rebuilt data source.
Instructions
Infer column types by sampling the head of a data file (CSV/Excel/JSON/JSONL) and generate a draft V2 schema structure. Use it when creating a schema for a new data source or rebuilding an existing schema; read-only, nothing is written to disk - the caller decides whether to save the returned draft. Returns a schema dictionary with V2 fields such as id, name and columns (each column carries its inferred type: string/integer/float/decimal/boolean/date). Note: type inference is based on a sample (1000 rows by default), so extreme values outside the sample may change the actual type; review the draft by hand before verifying it with validate_data. The file path must be inside the server working directory, otherwise the call fails.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| table_id | No | Table ID. Pass the existing id when replacing a schema to preserve references; a new id is generated otherwise | |
| data_file | Yes | Path to a CSV/Excel/JSON/JSONL data file (must be inside the server working directory; paths outside it are rejected) | |
| table_name | No | Table display name; defaults to the data file name | |
| sample_rows | No | Number of rows to sample (default 1000; must be a positive integer). Larger samples infer types more accurately but run slower | |
| source_path | No | source.path written into the schema (path to the data file, relative); omitted when not provided |