Skip to content

Commit

Permalink
Impliment file_uris (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
xbrianh authored Oct 11, 2024
1 parent d61921f commit f5e1eb8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_xdlake.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,14 @@ def gen_frames():
xdl.to_pyarrow_table()
)

def test_file_uris(self):
number_of_writes = 3
xdl = xdlake.DeltaTable(f"{self.scratch_folder}/{uuid4()}")
for _ in range(number_of_writes):
xdl = xdl.write(self.gen_table())
self.assertEqual(number_of_writes, len(xdl.file_uris()))
for uri in xdl.file_uris():
self.assertTrue(uri.startswith("file://"))

if __name__ == '__main__':
unittest.main()
5 changes: 5 additions & 0 deletions xdlake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ def get_fragments(self) -> dict[str, list[pyarrow.dataset.Fragment]]:
fragments[loc.fs].append(fragment)
return dict(fragments)

def file_uris(self) -> list[str]:
"""Return the URI for each file in the current version of the table."""
return [storage.absloc(add.path, self.loc).url
for add in self.adds.values()]

def to_pyarrow_dataset(self) -> pyarrow.dataset.Dataset:
"""Return arrow dataset."""
datasets = list()
Expand Down

0 comments on commit f5e1eb8

Please sign in to comment.