Skip to content

Commit b48d36b

Browse files
NhuanTDBKNHUAN.TRAN
andauthored
feat: Filter subset features in postgres #3174 (#3203)
* Filter subset features Signed-off-by: NHUAN.TRAN <nhuan.tran@onemount.com> Signed-off-by: NHUAN.TRAN <NhuanTDBK@users.noreply.github.com> * Fix python lint Signed-off-by: NHUAN.TRAN <NhuanTDBK@users.noreply.github.com> Signed-off-by: NHUAN.TRAN <nhuan.tran@onemount.com> Signed-off-by: NHUAN.TRAN <NhuanTDBK@users.noreply.github.com> Co-authored-by: NHUAN.TRAN <nhuan.tran@onemount.com>
1 parent cb8db84 commit b48d36b

File tree

1 file changed

+24
-11
lines changed
  • sdk/python/feast/infra/online_stores/contrib

1 file changed

+24
-11
lines changed

sdk/python/feast/infra/online_stores/contrib/postgres.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,30 @@ def online_read(
114114
)
115115
)
116116

117-
cur.execute(
118-
sql.SQL(
119-
"""
120-
SELECT entity_key, feature_name, value, event_ts
121-
FROM {} WHERE entity_key = ANY(%s);
122-
"""
123-
).format(
124-
sql.Identifier(_table_id(project, table)),
125-
),
126-
(keys,),
127-
)
117+
if not requested_features:
118+
cur.execute(
119+
sql.SQL(
120+
"""
121+
SELECT entity_key, feature_name, value, event_ts
122+
FROM {} WHERE entity_key = ANY(%s);
123+
"""
124+
).format(
125+
sql.Identifier(_table_id(project, table)),
126+
),
127+
(keys,),
128+
)
129+
else:
130+
cur.execute(
131+
sql.SQL(
132+
"""
133+
SELECT entity_key, feature_name, value, event_ts
134+
FROM {} WHERE entity_key = ANY(%s) and feature_name = ANY(%s);
135+
"""
136+
).format(
137+
sql.Identifier(_table_id(project, table)),
138+
),
139+
(keys, requested_features),
140+
)
128141

129142
rows = cur.fetchall()
130143

0 commit comments

Comments
 (0)