Skip to content

Commit

Permalink
fix(duckdb): ensure that paths with non-extension . chars are parse…
Browse files Browse the repository at this point in the history
…d correctly
  • Loading branch information
cpcloud committed Jul 12, 2022
1 parent e304b91 commit 9448fd3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ibis/backends/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def _csv(_, path, table_name=None):

@_register.register(r"(?:file://)?(?P<path>.+)", priority=9)
def _file(_, path, table_name=None):
*_, extension = str(path).split(os.extsep, 1)
num_sep_chars = len(os.extsep)
extension = "".join(Path(path).suffixes)[num_sep_chars:]
return _register(f"{extension}://{path}", table_name=table_name)


Expand Down
12 changes: 12 additions & 0 deletions ibis/backends/duckdb/tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ def test_register_csv(
assert table.count().execute()


def test_register_with_dotted_name(data_directory, tmp_path):
con = ibis.duckdb.connect()
basename = "foo.bar.baz/diamonds.csv"
f = tmp_path.joinpath(basename)
f.parent.mkdir()
data = data_directory.joinpath("diamonds.csv").read_bytes()
f.write_bytes(data)
con.register(str(f.absolute()))
table = con.table("diamonds")
assert table.count().execute()


@pytest.mark.parametrize(
"fname, in_table_name, out_table_name",
[
Expand Down

0 comments on commit 9448fd3

Please sign in to comment.