File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
sdk/python/feast/infra/online_stores/contrib/mysql_online_store Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -178,18 +178,28 @@ def update(
178178
179179 # We don't create any special state for the entities in this implementation.
180180 for table in tables_to_keep :
181+
182+ table_name = _table_id (project , table )
183+ index_name = f"{ table_name } _ek"
181184 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),
183186 feature_name VARCHAR(256),
184187 value BLOB,
185188 event_ts timestamp NULL DEFAULT NULL,
186189 created_ts timestamp NULL DEFAULT NULL,
187190 PRIMARY KEY(entity_key, feature_name))"""
188191 )
189192
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+ """
192198 )
199+ if not index_exists :
200+ cur .execute (
201+ f"ALTER TABLE { table_name } ADD INDEX { index_name } (entity_key);"
202+ )
193203
194204 for table in tables_to_delete :
195205 _drop_table_and_index (cur , project , table )
You can’t perform that action at this time.
0 commit comments