Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make entity description optional and fix empty table_ref #1425

Merged
merged 3 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/python/feast/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def to_proto(self) -> DataSourceProto:

def get_table_query_string(self) -> str:
"""Returns a string that can directly be used to reference this table in SQL"""
if self.table_ref is not None:
if self.table_ref:
return f"`{self.table_ref}`"
else:
return f"({self.query})"
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/feast/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class Entity:
def __init__(
self,
name: str,
description: str,
value_type: ValueType,
description: str = "",
jklegar marked this conversation as resolved.
Show resolved Hide resolved
labels: Optional[MutableMapping[str, str]] = None,
):
self._name = name
Expand Down
5 changes: 1 addition & 4 deletions sdk/python/feast/offline_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,7 @@ def pull_latest_from_table_or_query(
end_date: datetime,
) -> pyarrow.Table:
assert isinstance(data_source, BigQuerySource)
if data_source.table_ref:
from_expression = f"`{data_source.table_ref}`"
else:
from_expression = f"({data_source.query})"
from_expression = data_source.get_table_query_string()

partition_by_entity_string = ", ".join(entity_names)
if partition_by_entity_string != "":
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/tests/online_write_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def benchmark_writes():
# This is just to set data source to something, we're not reading from parquet source here.
parquet_path = os.path.join(temp_dir, "data.parquet")

driver = Entity(name="driver_id", value_type=ValueType.INT64, description="")
driver = Entity(name="driver_id", value_type=ValueType.INT64)
table = create_driver_hourly_stats_feature_view(
create_driver_hourly_stats_source(parquet_path=parquet_path)
)
Expand Down
4 changes: 4 additions & 0 deletions sdk/python/tests/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@ def test_entity_without_labels_empty_dict():
entity = Entity("my-entity", description="My entity", value_type=ValueType.STRING)
assert entity.labels == dict()
assert len(entity.labels) == 0


def test_entity_without_description():
Entity("my-entity", value_type=ValueType.STRING)
8 changes: 4 additions & 4 deletions sdk/python/tests/test_historical_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ def test_historical_features_from_parquet_sources():
temp_dir, customer_df
)
customer_fv = create_customer_daily_profile_feature_view(customer_source)
driver = Entity(name="driver", value_type=ValueType.INT64, description="")
customer = Entity(name="customer", value_type=ValueType.INT64, description="")
driver = Entity(name="driver", value_type=ValueType.INT64)
customer = Entity(name="customer", value_type=ValueType.INT64)

store = FeatureStore(
config=RepoConfig(
Expand Down Expand Up @@ -326,8 +326,8 @@ def test_historical_features_from_bigquery_sources():
)
customer_fv = create_customer_daily_profile_feature_view(customer_source)

driver = Entity(name="driver", value_type=ValueType.INT64, description="")
customer = Entity(name="customer", value_type=ValueType.INT64, description="")
driver = Entity(name="driver", value_type=ValueType.INT64)
customer = Entity(name="customer", value_type=ValueType.INT64)

store = FeatureStore(
config=RepoConfig(
Expand Down