|
16 | 16 |
|
17 | 17 |
|
18 | 18 | from hsfs import ( |
| 19 | + feature_store, |
19 | 20 | feature_group, |
20 | 21 | user, |
21 | 22 | statistics_config, |
22 | 23 | feature, |
23 | 24 | storage_connector, |
24 | 25 | expectation_suite, |
| 26 | + util, |
25 | 27 | ) |
| 28 | +from hsfs.client.exceptions import FeatureStoreException |
| 29 | +import pytest |
| 30 | +import warnings |
26 | 31 |
|
27 | 32 |
|
28 | 33 | class TestFeatureGroup: |
@@ -220,6 +225,35 @@ def test_from_response_json_stream_basic_info(self, backend_fixtures): |
220 | 225 | assert fg.stream is True |
221 | 226 | assert fg.expectation_suite is None |
222 | 227 |
|
| 228 | + def test_constructor_with_list_event_time_for_compatibility( |
| 229 | + self, mocker, backend_fixtures, dataframe_fixture_basic |
| 230 | + ): |
| 231 | + # Arrange |
| 232 | + mocker.patch("hsfs.client.get_instance") |
| 233 | + mocker.patch("hsfs.engine.get_type") |
| 234 | + json = backend_fixtures["feature_store"]["get"]["response"] |
| 235 | + |
| 236 | + # Act |
| 237 | + fs = feature_store.FeatureStore.from_response_json(json) |
| 238 | + with warnings.catch_warnings(record=True) as warning_record: |
| 239 | + new_fg = fs.create_feature_group( |
| 240 | + name="fg_name", |
| 241 | + version=1, |
| 242 | + description="fg_description", |
| 243 | + event_time=["event_date"], |
| 244 | + ) |
| 245 | + with pytest.raises(FeatureStoreException): |
| 246 | + util.verify_attribute_key_names(new_fg, False) |
| 247 | + |
| 248 | + # Assert |
| 249 | + assert new_fg.event_time == "event_date" |
| 250 | + assert len(warning_record) == 1 |
| 251 | + assert issubclass(warning_record[0].category, DeprecationWarning) |
| 252 | + assert str(warning_record[0].message) == ( |
| 253 | + "Providing event_time as a single-element list is deprecated" |
| 254 | + + " and will be dropped in future versions. Provide the feature_name string instead." |
| 255 | + ) |
| 256 | + |
223 | 257 |
|
224 | 258 | class TestExternalFeatureGroup: |
225 | 259 | def test_from_response_json(self, backend_fixtures): |
|
0 commit comments