1111 DynamoDBOnlineStoreConfig ,
1212 DynamoDBTable ,
1313)
14+ from feast .protos .feast .types .EntityKey_pb2 import EntityKey as EntityKeyProto
15+ from feast .protos .feast .types .Value_pb2 import Value as ValueProto
1416from feast .repo_config import RepoConfig
1517from tests .utils .online_store_utils import (
1618 _create_n_customer_test_samples ,
@@ -49,7 +51,6 @@ def test_online_store_config_default():
4951 assert dynamodb_store_config .batch_size == 40
5052 assert dynamodb_store_config .endpoint_url is None
5153 assert dynamodb_store_config .region == aws_region
52- assert dynamodb_store_config .sort_response is True
5354 assert dynamodb_store_config .table_name_template == "{project}.{table_name}"
5455
5556
@@ -70,20 +71,17 @@ def test_online_store_config_custom_params():
7071 aws_region = "us-west-2"
7172 batch_size = 20
7273 endpoint_url = "http://localhost:8000"
73- sort_response = False
7474 table_name_template = "feast_test.dynamodb_table"
7575 dynamodb_store_config = DynamoDBOnlineStoreConfig (
7676 region = aws_region ,
7777 batch_size = batch_size ,
7878 endpoint_url = endpoint_url ,
79- sort_response = sort_response ,
8079 table_name_template = table_name_template ,
8180 )
8281 assert dynamodb_store_config .type == "dynamodb"
8382 assert dynamodb_store_config .batch_size == batch_size
8483 assert dynamodb_store_config .endpoint_url == endpoint_url
8584 assert dynamodb_store_config .region == aws_region
86- assert dynamodb_store_config .sort_response == sort_response
8785 assert dynamodb_store_config .table_name_template == table_name_template
8886
8987
@@ -175,6 +173,42 @@ def test_online_read(repo_config, n_samples):
175173 assert [item [1 ] for item in returned_items ] == list (features )
176174
177175
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+
178212@mock_dynamodb2
179213def test_write_batch_non_duplicates (repo_config ):
180214 """Test DynamoDBOnline Store deduplicate write batch request items."""
0 commit comments