Commit 3defc29 1 parent 9a3590e commit 3defc29 Copy full SHA for 3defc29
File tree 1 file changed +13
-3
lines changed
sdk/python/feast/infra/online_stores/contrib/mysql_online_store
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -178,18 +178,28 @@ def update(
178
178
179
179
# We don't create any special state for the entities in this implementation.
180
180
for table in tables_to_keep :
181
+
182
+ table_name = _table_id (project , table )
183
+ index_name = f"{ table_name } _ek"
181
184
cur .execute (
182
- f"""CREATE TABLE IF NOT EXISTS { _table_id ( project , table ) } (entity_key VARCHAR(512),
185
+ f"""CREATE TABLE IF NOT EXISTS { table_name } (entity_key VARCHAR(512),
183
186
feature_name VARCHAR(256),
184
187
value BLOB,
185
188
event_ts timestamp NULL DEFAULT NULL,
186
189
created_ts timestamp NULL DEFAULT NULL,
187
190
PRIMARY KEY(entity_key, feature_name))"""
188
191
)
189
192
190
- cur .execute (
191
- f"ALTER TABLE { _table_id (project , table )} ADD INDEX { _table_id (project , table )} _ek (entity_key);"
193
+ index_exists = cur .execute (
194
+ f"""
195
+ SELECT 1 FROM information_schema.statistics
196
+ WHERE table_schema = DATABASE() AND table_name = '{ table_name } ' AND index_name = '{ index_name } '
197
+ """
192
198
)
199
+ if not index_exists :
200
+ cur .execute (
201
+ f"ALTER TABLE { table_name } ADD INDEX { index_name } (entity_key);"
202
+ )
193
203
194
204
for table in tables_to_delete :
195
205
_drop_table_and_index (cur , project , table )
You can’t perform that action at this time.
0 commit comments