11
11
DynamoDBOnlineStoreConfig ,
12
12
DynamoDBTable ,
13
13
)
14
+ from feast .protos .feast .types .EntityKey_pb2 import EntityKey as EntityKeyProto
15
+ from feast .protos .feast .types .Value_pb2 import Value as ValueProto
14
16
from feast .repo_config import RepoConfig
15
17
from tests .utils .online_store_utils import (
16
18
_create_n_customer_test_samples ,
@@ -49,7 +51,6 @@ def test_online_store_config_default():
49
51
assert dynamodb_store_config .batch_size == 40
50
52
assert dynamodb_store_config .endpoint_url is None
51
53
assert dynamodb_store_config .region == aws_region
52
- assert dynamodb_store_config .sort_response is True
53
54
assert dynamodb_store_config .table_name_template == "{project}.{table_name}"
54
55
55
56
@@ -70,20 +71,17 @@ def test_online_store_config_custom_params():
70
71
aws_region = "us-west-2"
71
72
batch_size = 20
72
73
endpoint_url = "http://localhost:8000"
73
- sort_response = False
74
74
table_name_template = "feast_test.dynamodb_table"
75
75
dynamodb_store_config = DynamoDBOnlineStoreConfig (
76
76
region = aws_region ,
77
77
batch_size = batch_size ,
78
78
endpoint_url = endpoint_url ,
79
- sort_response = sort_response ,
80
79
table_name_template = table_name_template ,
81
80
)
82
81
assert dynamodb_store_config .type == "dynamodb"
83
82
assert dynamodb_store_config .batch_size == batch_size
84
83
assert dynamodb_store_config .endpoint_url == endpoint_url
85
84
assert dynamodb_store_config .region == aws_region
86
- assert dynamodb_store_config .sort_response == sort_response
87
85
assert dynamodb_store_config .table_name_template == table_name_template
88
86
89
87
@@ -175,6 +173,42 @@ def test_online_read(repo_config, n_samples):
175
173
assert [item [1 ] for item in returned_items ] == list (features )
176
174
177
175
176
+ @mock_dynamodb2
177
+ def test_online_read_unknown_entity (repo_config ):
178
+ """Test DynamoDBOnlineStore online_read method."""
179
+ n_samples = 2
180
+ _create_test_table (PROJECT , f"{ TABLE_NAME } _{ n_samples } " , REGION )
181
+ data = _create_n_customer_test_samples (n = n_samples )
182
+ _insert_data_test_table (data , PROJECT , f"{ TABLE_NAME } _{ n_samples } " , REGION )
183
+
184
+ entity_keys , features , * rest = zip (* data )
185
+ # Append a nonsensical entity to search for
186
+ entity_keys = list (entity_keys )
187
+ features = list (features )
188
+ dynamodb_store = DynamoDBOnlineStore ()
189
+
190
+ # Have the unknown entity be in the beginning, middle, and end of the list of entities.
191
+ for pos in range (len (entity_keys )):
192
+ entity_keys_with_unknown = deepcopy (entity_keys )
193
+ entity_keys_with_unknown .insert (
194
+ pos ,
195
+ EntityKeyProto (
196
+ join_keys = ["customer" ], entity_values = [ValueProto (string_val = "12359" )]
197
+ ),
198
+ )
199
+ features_with_none = deepcopy (features )
200
+ features_with_none .insert (pos , None )
201
+ returned_items = dynamodb_store .online_read (
202
+ config = repo_config ,
203
+ table = MockFeatureView (name = f"{ TABLE_NAME } _{ n_samples } " ),
204
+ entity_keys = entity_keys_with_unknown ,
205
+ )
206
+ assert len (returned_items ) == len (entity_keys_with_unknown )
207
+ assert [item [1 ] for item in returned_items ] == list (features_with_none )
208
+ # The order should match the original entity key order
209
+ assert returned_items [pos ] == (None , None )
210
+
211
+
178
212
@mock_dynamodb2
179
213
def test_write_batch_non_duplicates (repo_config ):
180
214
"""Test DynamoDBOnline Store deduplicate write batch request items."""
0 commit comments