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

chore(dao): Remove redundant convenience methods #24967

Merged
Show file tree
Hide file tree
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
52 changes: 0 additions & 52 deletions superset/daos/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,31 +301,6 @@ def find_dataset_column(cls, dataset_id: int, column_id: int) -> TableColumn | N
.one_or_none()
)

@classmethod
def update_column(
cls,
model: TableColumn,
properties: dict[str, Any],
commit: bool = True,
) -> TableColumn:
return DatasetColumnDAO.update(model, properties, commit=commit)

@classmethod
def create_column(
cls, properties: dict[str, Any], commit: bool = True
) -> TableColumn:
"""
Creates a Dataset model on the metadata DB
"""
return DatasetColumnDAO.create(attributes=properties, commit=commit)

@classmethod
def delete_column(cls, model: TableColumn, commit: bool = True) -> None:
"""
Deletes a Dataset column
"""
DatasetColumnDAO.delete(model, commit=commit)

@classmethod
def find_dataset_metric(cls, dataset_id: int, metric_id: int) -> SqlMetric | None:
# We want to apply base dataset filters
Expand All @@ -334,33 +309,6 @@ def find_dataset_metric(cls, dataset_id: int, metric_id: int) -> SqlMetric | Non
return None
return db.session.query(SqlMetric).get(metric_id)

@classmethod
def delete_metric(cls, model: SqlMetric, commit: bool = True) -> None:
"""
Deletes a Dataset metric
"""
DatasetMetricDAO.delete(model, commit=commit)

@classmethod
def update_metric(
cls,
model: SqlMetric,
properties: dict[str, Any],
commit: bool = True,
) -> SqlMetric:
return DatasetMetricDAO.update(model, properties, commit=commit)

@classmethod
def create_metric(
cls,
properties: dict[str, Any],
commit: bool = True,
) -> SqlMetric:
"""
Creates a Dataset model on the metadata DB
"""
return DatasetMetricDAO.create(attributes=properties, commit=commit)

@classmethod
def delete(
cls,
Expand Down
4 changes: 2 additions & 2 deletions superset/datasets/columns/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from superset import security_manager
from superset.commands.base import BaseCommand
from superset.connectors.sqla.models import TableColumn
from superset.daos.dataset import DatasetDAO
from superset.daos.dataset import DatasetColumnDAO, DatasetDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.datasets.columns.commands.exceptions import (
DatasetColumnDeleteFailedError,
Expand All @@ -43,7 +43,7 @@ def run(self) -> None:
assert self._model

try:
DatasetDAO.delete_column(self._model)
DatasetColumnDAO.delete(self._model)
except DAODeleteFailedError as ex:
logger.exception(ex.exception)
raise DatasetColumnDeleteFailedError() from ex
Expand Down
4 changes: 2 additions & 2 deletions superset/datasets/metrics/commands/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from superset import security_manager
from superset.commands.base import BaseCommand
from superset.connectors.sqla.models import SqlMetric
from superset.daos.dataset import DatasetDAO
from superset.daos.dataset import DatasetDAO, DatasetMetricDAO
from superset.daos.exceptions import DAODeleteFailedError
from superset.datasets.metrics.commands.exceptions import (
DatasetMetricDeleteFailedError,
Expand All @@ -43,7 +43,7 @@ def run(self) -> None:
assert self._model

try:
DatasetDAO.delete_metric(self._model)
DatasetMetricDAO.delete(self._model)
except DAODeleteFailedError as ex:
logger.exception(ex.exception)
raise DatasetMetricDeleteFailedError() from ex
Expand Down