diff --git a/sdk/python/feast/infra/offline_stores/duckdb.py b/sdk/python/feast/infra/offline_stores/duckdb.py index 1ff09d9f3cf..ebca2245d46 100644 --- a/sdk/python/feast/infra/offline_stores/duckdb.py +++ b/sdk/python/feast/infra/offline_stores/duckdb.py @@ -95,6 +95,13 @@ def _read_data_source(data_source: DataSource, repo_path: str) -> Table: if storage_options: return ibis.read_delta(data_source.path, storage_options=storage_options) return ibis.read_delta(data_source.path) + else: + raise ValueError( + f"Unable to determine the file format for data source " + f"'{data_source.name}' with path '{data_source.path}'. Either set " + f"'file_format' explicitly on the FileSource (e.g. ParquetFormat()) " + f"or use a path with a recognized file extension (e.g. '.parquet')." + ) def _read_iceberg_catalog_source(data_source: "IcebergSource", repo_path: str) -> Table: diff --git a/sdk/python/tests/unit/infra/offline_stores/test_duckdb.py b/sdk/python/tests/unit/infra/offline_stores/test_duckdb.py new file mode 100644 index 00000000000..1ed46279a8b --- /dev/null +++ b/sdk/python/tests/unit/infra/offline_stores/test_duckdb.py @@ -0,0 +1,15 @@ +import pytest + +from feast.infra.offline_stores.duckdb import _read_data_source +from feast.infra.offline_stores.file_source import FileSource + + +def test_read_data_source_raises_on_unresolvable_file_format(): + data_source = FileSource( + name="driver_hourly_stats_source", + path="data/driver_stats.csv", + timestamp_field="event_timestamp", + ) + + with pytest.raises(ValueError, match="Unable to determine the file format"): + _read_data_source(data_source, repo_path=".")