Skip to content

Commit 524e98c

Browse files
Prathap-PPrathap P
andauthored
fix: Adapt project_id_exists validator for updated pydantic version (#4680)
* adapt project_id_exists validator for updated pydantic version Signed-off-by: Prathap P <Prathap.P@walmart.com> * fix linting issues Signed-off-by: Prathap P <Prathap.P@walmart.com> * fix linting issue Signed-off-by: Prathap P <Prathap.P@walmart.com> --------- Signed-off-by: Prathap P <Prathap.P@walmart.com> Co-authored-by: Prathap P <Prathap.P@walmart.com>
1 parent 00be7b0 commit 524e98c

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎sdk/python/feast/infra/offline_stores/bigquery.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class BigQueryOfflineStoreConfig(FeastConfigBaseModel):
114114

115115
@field_validator("billing_project_id")
116116
def project_id_exists(cls, v, values, **kwargs):
117-
if v and not values["project_id"]:
117+
if v and not (values.data and values.data["project_id"]):
118118
raise ValueError(
119119
"please specify project_id if billing_project_id is specified"
120120
)

‎sdk/python/tests/unit/infra/offline_stores/test_bigquery.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,29 @@ def test_to_arrow_timeout(self, big_query_result):
8282
self.retrieval_job._execute_query.assert_called_once_with(
8383
query=self.query, timeout=30
8484
)
85+
86+
87+
class TestBigQueryRetrievalJobWithBillingProject:
88+
query = "SELECT * FROM bigquery"
89+
client = Mock()
90+
91+
def test_project_id_exists(self):
92+
with pytest.raises(ValueError):
93+
retrieval_job = BigQueryRetrievalJob(
94+
query=self.query,
95+
client=self.client,
96+
config=RepoConfig(
97+
registry="gs://ml-test/repo/registry.db",
98+
project="test",
99+
provider="gcp",
100+
online_store=SqliteOnlineStoreConfig(type="sqlite"),
101+
offline_store=BigQueryOfflineStoreConfig(
102+
type="bigquery",
103+
dataset="feast",
104+
billing_project_id="test-billing-project",
105+
),
106+
),
107+
full_feature_names=True,
108+
on_demand_feature_views=[],
109+
)
110+
retrieval_job.to_df()

0 commit comments

Comments
 (0)