Skip to content

CSV Reader INTERNAL Error on size mismatch between columns and header #5662

@Tishj

Description

@Tishj

What happens?

When reading a csv header=true, and also explicitly supplying columns, when they don't match an InternalException is thrown. Similar to:

  File "/Users/thijs/DuckDBLabs/duckdb/tmp/mismatch_csv.py", line 13, in <module>
    data = con.execute(q2).fetchall()
duckdb.InternalException: INTERNAL Error: Assertion triggered in file "/Users/thijs/DuckDBLabs/duckdb/src/function/table/read_csv.cpp" on line 113: return_types.size() == names.size()

Note: I'm sure this can also be reproduced as a .test file, for convenience I've supplied the example using the python client.

To Reproduce

test.csv

a, b, c, d
1, 2, 3, 4
import duckdb

con=duckdb.connect()
columns="{'a':'varchar','b':'varchar','c':'varchar','d':'varchar','e':'varchar'}"
q2=f"""
	SELECT * FROM read_csv_auto(
		'test.csv',
		delim='/t',
		header=True,
		columns={columns}
	)
	"""
data = con.execute(q2).fetchall()
print(data)

OS:

MacOS

DuckDB Version:

master

DuckDB Client:

Python

Full Name:

Thijs Bruineman

Affiliation:

DuckDB Labs

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions