Skip to content

Commit

Permalink
Merge pull request #264 from opentargets/il-empty-parquet
Browse files Browse the repository at this point in the history
feat: raise error in `from_parquet` when df is empty
  • Loading branch information
tskir authored Nov 21, 2023
2 parents 85288f2 + a4393fd commit 6b33ddd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/otg/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,14 @@ def from_parquet(
Returns:
Self: Dataset with the parquet file contents
Raises:
ValueError: Parquet file is empty
"""
schema = cls.get_schema()
df = session.read_parquet(path=path, schema=schema, **kwargs)
if df.isEmpty():
raise ValueError(f"Parquet file is empty: {path}")
return cls(_df=df, _schema=schema)

def validate_schema(self: Dataset) -> None:
Expand Down

0 comments on commit 6b33ddd

Please sign in to comment.