Skip to content

Commit c81dc27

Browse files
committed
Add simple unittest for _get_unique_entities
Signed-off-by: Judah Rand <17158624+judahrand@users.noreply.github.com>
1 parent 39a5812 commit c81dc27

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from dataclasses import dataclass
2+
from typing import Dict, List
3+
4+
from feast import FeatureStore
5+
from feast.protos.feast.types.Value_pb2 import Value
6+
7+
8+
@dataclass
9+
class MockFeatureViewProjection:
10+
join_key_map: Dict[str, str]
11+
12+
13+
@dataclass
14+
class MockFeatureView:
15+
name: str
16+
entities: List[str]
17+
projection: MockFeatureViewProjection
18+
19+
20+
def test__get_unique_entities():
21+
entity_values = {
22+
"entity_1": [Value(int64_val=1), Value(int64_val=2), Value(int64_val=1)],
23+
"entity_2": [
24+
Value(string_val="1"),
25+
Value(string_val="2"),
26+
Value(string_val="1"),
27+
],
28+
"entity_3": [Value(int64_val=8), Value(int64_val=9), Value(int64_val=10)],
29+
}
30+
31+
entity_name_to_join_key_map = {"entity_1": "entity_1", "entity_2": "entity_2"}
32+
33+
fv = MockFeatureView(
34+
name="fv_1",
35+
entities=["entity_1", "entity_2"],
36+
projection=MockFeatureViewProjection(join_key_map={}),
37+
)
38+
39+
unique_entities, indexes = FeatureStore._get_unique_entities(
40+
FeatureStore,
41+
table=fv,
42+
join_key_values=entity_values,
43+
entity_name_to_join_key_map=entity_name_to_join_key_map,
44+
)
45+
46+
assert unique_entities == (
47+
{"entity_1": Value(int64_val=1), "entity_2": Value(string_val="1")},
48+
{"entity_1": Value(int64_val=2), "entity_2": Value(string_val="2")},
49+
)
50+
assert indexes == ([0, 2], [1])

0 commit comments

Comments
 (0)