Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support separators in doc_id #108

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions hq_superset/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass
from typing import Any
from typing import Any, Optional

from authlib.integrations.sqla_oauth2 import (
OAuth2ClientMixin,
Expand Down Expand Up @@ -34,6 +34,7 @@ class DataSetChange:
data_source_id: str
doc_id: str
data: list[dict[str, Any]]
doc_ids: Optional[list[str]]

def update_dataset(self):
with statsd.timed('cca.dataset_change.timer', tags=get_tags({"datasource": self.data_source_id})):
Expand Down Expand Up @@ -66,7 +67,10 @@ 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.doc_ids:
delete_stmt = table.delete().where(table.c.doc_id.in_(self.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