pub fn infer_csv_schema(
csv_text: &str,
has_header: bool,
) -> Result<Vec<ColumnSchema>, McpError>Expand description
Infer a ColumnSchema for each CSV column (Tier 3).
When has_header is true, the first row provides column names; otherwise
columns are named col_0, col_1, etc. Up to 1 000 data rows are sampled
to determine types. All CSV columns are marked nullable because CSV has no
way to express a NOT NULL constraint.
§Errors
- Returns
ErrorCode::SchemaMismatchwhen the CSV header line or any sampled record cannot be parsed. - Returns
ErrorCode::EmptyDatawhen there are no data rows (to infer column count in the headerless case) or when the header row is empty.