Skip to content

Commit

Permalink
Support separators in doc_id
Browse files Browse the repository at this point in the history
  • Loading branch information
kaapstorm committed Feb 3, 2025
1 parent a19071d commit 7f7fb04
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion hq_superset/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class DataSetChange:
doc_id: str
data: list[dict[str, Any]]

SEP = ','

def update_dataset(self):
with statsd.timed('cca.dataset_change.timer', tags=get_tags({"datasource": self.data_source_id})):
self._update_dataset()
Expand Down Expand Up @@ -66,7 +68,11 @@ def _update_dataset(self):
engine.connect() as connection,
connection.begin() # Commit on leaving context
):
delete_stmt = table.delete().where(table.c.doc_id == self.doc_id)
if self.SEP in self.doc_id:
doc_ids = self.doc_id.split(self.SEP)
delete_stmt = table.delete().where(table.c.doc_id.in_(doc_ids))
else:
delete_stmt = table.delete().where(table.c.doc_id == self.doc_id)
connection.execute(delete_stmt)
if self.data:
rows = list(cast_data_for_table(self.data, table))
Expand Down

0 comments on commit 7f7fb04

Please sign in to comment.