Skip to content

Commit

Permalink
feat(duckdb): set header=True by default
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Some CSV files may now have headers that did not have them previously. Set `header=False` to get the previous behavior.
  • Loading branch information
cpcloud committed Apr 19, 2023
1 parent c0d1487 commit e4b515d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions ibis/backends/duckdb/__init__.py
Expand Up @@ -306,6 +306,7 @@ def read_csv(
if any(source.startswith(("http://", "https://")) for source in source_list):
self._load_extensions(["httpfs"])

kwargs.setdefault("header", True)
kwargs["auto_detect"] = kwargs.pop("auto_detect", "columns" not in kwargs)
source = sa.select(sa.literal_column("*")).select_from(
sa.func.read_csv(sa.func.list_value(*source_list), _format_kwargs(kwargs))
Expand Down
20 changes: 20 additions & 0 deletions ibis/examples/tests/test_examples.py
Expand Up @@ -51,3 +51,23 @@ def test_non_example():
gobbledygook = f"{ibis.util.guid()}"
with pytest.raises(AttributeError, match=gobbledygook):
getattr(ibis.examples, gobbledygook)


@pytest.mark.duckdb
@pytest.mark.backend
@pytest.mark.xfail(
LINUX and SANDBOXED,
reason="nix on linux cannot download duckdb extensions or data due to sandboxing",
raises=OSError,
)
@pytest.mark.parametrize(
("example", "expected"),
[
("band_members", ["name", "band"]),
("band_instruments", ["name", "plays"]),
("band_instruments2", ["artist", "plays"]),
],
ids=["members", "instruments", "instruments2"],
)
def test_band(example, expected):
assert getattr(ibis.examples, example).fetch().columns == expected

0 comments on commit e4b515d

Please sign in to comment.