You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "jfrag1 (via GitHub)" <gi...@apache.org> on 2023/08/05 00:10:58 UTC

[GitHub] [superset] jfrag1 opened a new pull request, #24894: chore: Update DAOs to use singular deletion method instead of bulk

jfrag1 opened a new pull request, #24894:
URL: https://github.com/apache/superset/pull/24894

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   This change shouldn't have any impact on the behavior of the application outside of maybe a small performance hit when deleting many objects at once.  Note additionally that this is the default method of deletion used by the `BaseDAO`.
   
   The motivation behind the change is that at Preset we'd like the ability to utilize the `after_delete` sqlalchemy listener hooks for these objects, and these aren't triggered for bulk deletes.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] jfrag1 commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "jfrag1 (via GitHub)" <gi...@apache.org>.
jfrag1 commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1284935336


##########
tests/integration_tests/datasets/api_tests.py:
##########
@@ -1711,12 +1712,15 @@ def test_bulk_delete_dataset_items(self):
         assert rv.status_code == 200
         expected_response = {"message": f"Deleted {len(datasets)} datasets"}
         assert data == expected_response
+        deleted_datasets = datasets
         datasets = (
             db.session.query(SqlaTable)
             .filter(SqlaTable.table_name.in_(self.fixture_tables_names))
             .all()
         )
         assert datasets == []
+        for dataset in deleted_datasets:
+            setattr(dataset, "_deleted", True)

Review Comment:
   This test started failing since the cleanup was trying to delete already-deleted datasets.  This was fine for some reason before with the bulk-deletes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286143273


##########
superset/daos/chart.py:
##########
@@ -41,16 +41,14 @@ class ChartDAO(BaseDAO[Slice]):
 
     @classmethod
     def delete(cls, items: Slice | list[Slice], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   @jfrag1 if we're removing the bulk delete logic, i.e., deleting outside of the ORM, then I think there's merit in removing the entire function and falling back to `BaseDAO.delete`.



##########
tests/integration_tests/datasets/api_tests.py:
##########
@@ -1711,12 +1712,15 @@ def test_bulk_delete_dataset_items(self):
         assert rv.status_code == 200
         expected_response = {"message": f"Deleted {len(datasets)} datasets"}
         assert data == expected_response
+        deleted_datasets = datasets
         datasets = (
             db.session.query(SqlaTable)
             .filter(SqlaTable.table_name.in_(self.fixture_tables_names))
             .all()
         )
         assert datasets == []
+        for dataset in deleted_datasets:
+            setattr(dataset, "_deleted", True)

Review Comment:
   This approach doesn't see right, i.e., we shouldn't need to be setting/getting hidden attributes. If I were you, I would re-evaluate the failing tests and see what the issue is. Maybe the results weren't flushed or committed?



##########
superset/daos/dataset.py:
##########
@@ -360,42 +359,6 @@ def create_metric(
         """
         return DatasetMetricDAO.create(properties, commit=commit)
 
-    @classmethod
-    def delete(
-        cls,
-        items: SqlaTable | list[SqlaTable],
-        commit: bool = True,
-    ) -> None:
-        """
-        Delete the specified items(s) including their associated relationships.
-
-        Note that bulk deletion via `delete` does not dispatch the `after_delete` event
-        and thus the ORM event listener callback needs to be invoked manually.
-
-        :param items: The item(s) to delete
-        :param commit: Whether to commit the transaction
-        :raises DAODeleteFailedError: If the deletion failed
-        :see: https://docs.sqlalchemy.org/en/latest/orm/queryguide/dml.html
-        """
-
-        try:
-            db.session.query(SqlaTable).filter(
-                SqlaTable.id.in_(item.id for item in get_iterable(items))
-            ).delete(synchronize_session="fetch")
-
-            connection = db.session.connection()
-            mapper = next(iter(cls.model_cls.registry.mappers))  # type: ignore
-
-            for item in get_iterable(items):

Review Comment:
   Per the PR description this method actually _should_ handle bulk deletion correctly.



##########
superset/daos/dashboard.py:
##########
@@ -185,17 +185,15 @@ def update_charts_owners(model: Dashboard, commit: bool = True) -> Dashboard:
 
     @classmethod
     def delete(cls, items: Dashboard | list[Dashboard], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   See my previous comment.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] jfrag1 commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "jfrag1 (via GitHub)" <gi...@apache.org>.
jfrag1 commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286167282


##########
tests/integration_tests/datasets/api_tests.py:
##########
@@ -1711,12 +1712,15 @@ def test_bulk_delete_dataset_items(self):
         assert rv.status_code == 200
         expected_response = {"message": f"Deleted {len(datasets)} datasets"}
         assert data == expected_response
+        deleted_datasets = datasets
         datasets = (
             db.session.query(SqlaTable)
             .filter(SqlaTable.table_name.in_(self.fixture_tables_names))
             .all()
         )
         assert datasets == []
+        for dataset in deleted_datasets:
+            setattr(dataset, "_deleted", True)

Review Comment:
   Updated with a better method of checking whether the object was deleted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] jfrag1 commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "jfrag1 (via GitHub)" <gi...@apache.org>.
jfrag1 commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1294901535


##########
superset/daos/chart.py:
##########
@@ -41,16 +41,14 @@ class ChartDAO(BaseDAO[Slice]):
 
     @classmethod
     def delete(cls, items: Slice | list[Slice], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   updated the chart/dashboard DAOs to fall back to `BaseDAO.delete`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zephyring commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "zephyring (via GitHub)" <gi...@apache.org>.
zephyring commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286160849


##########
superset/daos/dataset.py:
##########
@@ -360,42 +359,6 @@ def create_metric(
         """
         return DatasetMetricDAO.create(properties, commit=commit)
 
-    @classmethod
-    def delete(
-        cls,
-        items: SqlaTable | list[SqlaTable],
-        commit: bool = True,
-    ) -> None:
-        """
-        Delete the specified items(s) including their associated relationships.
-
-        Note that bulk deletion via `delete` does not dispatch the `after_delete` event
-        and thus the ORM event listener callback needs to be invoked manually.
-
-        :param items: The item(s) to delete
-        :param commit: Whether to commit the transaction
-        :raises DAODeleteFailedError: If the deletion failed
-        :see: https://docs.sqlalchemy.org/en/latest/orm/queryguide/dml.html
-        """
-
-        try:
-            db.session.query(SqlaTable).filter(
-                SqlaTable.id.in_(item.id for item in get_iterable(items))
-            ).delete(synchronize_session="fetch")
-
-            connection = db.session.connection()
-            mapper = next(iter(cls.model_cls.registry.mappers))  # type: ignore
-
-            for item in get_iterable(items):
-                security_manager.dataset_after_delete(mapper, connection, item)

Review Comment:
   should there any test failing if we remove this? I think we should add a test here to catch if
   the vm is removed once dataset is deleted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1289224525


##########
superset/daos/chart.py:
##########
@@ -41,16 +41,14 @@ class ChartDAO(BaseDAO[Slice]):
 
     @classmethod
     def delete(cls, items: Slice | list[Slice], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   @jfrag1 I authored https://github.com/apache/superset/pull/24938 and https://github.com/apache/superset/pull/24939 which should help provide some clarity, i.e., that said code block is redundant as we're leaning on the database schema.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1289224525


##########
superset/daos/chart.py:
##########
@@ -41,16 +41,14 @@ class ChartDAO(BaseDAO[Slice]):
 
     @classmethod
     def delete(cls, items: Slice | list[Slice], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   @jfrag1 I authored https://github.com/apache/superset/pull/24938 which should aid with my suggestion above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286376208


##########
superset/daos/chart.py:
##########
@@ -41,16 +41,14 @@ class ChartDAO(BaseDAO[Slice]):
 
     @classmethod
     def delete(cls, items: Slice | list[Slice], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   @jfrag1 the reason this logic is required is likely because for non SQLAlchemy ORM operations, i.e., bulk deletion, the `ON DELETE CASCADE` isn't configured. The right solution would be (in a separate PR) to replicate the logic outlined in https://github.com/apache/superset/pull/24628 for the `dashboard_slices` table.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] jfrag1 commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "jfrag1 (via GitHub)" <gi...@apache.org>.
jfrag1 commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286153282


##########
superset/daos/dashboard.py:
##########
@@ -185,17 +185,15 @@ def update_charts_owners(model: Dashboard, commit: bool = True) -> Dashboard:
 
     @classmethod
     def delete(cls, items: Dashboard | list[Dashboard], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   same here, there's some logic which is specific to dashboards.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286376208


##########
superset/daos/chart.py:
##########
@@ -41,16 +41,14 @@ class ChartDAO(BaseDAO[Slice]):
 
     @classmethod
     def delete(cls, items: Slice | list[Slice], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   @jfrag1 the reason this logic is required is likely because for non SQLAlchemy ORM operations, i.e., bulk deletion, the `ON DELETE CASCADE` isn't configured. If one were to simply remove the bulk deletion logic then the `BaseDAO.delete` method should be suffice.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286376208


##########
superset/daos/chart.py:
##########
@@ -41,16 +41,14 @@ class ChartDAO(BaseDAO[Slice]):
 
     @classmethod
     def delete(cls, items: Slice | list[Slice], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   @jfrag1 the reason this logic is required is likely because `ON DELETE CASCADE` isn't configured. The right solution would be (in a separate PR) to replicate the logic outlined in https://github.com/apache/superset/pull/24628 for the `dashboard_slices` table.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] jfrag1 commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "jfrag1 (via GitHub)" <gi...@apache.org>.
jfrag1 commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286166568


##########
superset/daos/dataset.py:
##########
@@ -360,42 +359,6 @@ def create_metric(
         """
         return DatasetMetricDAO.create(properties, commit=commit)
 
-    @classmethod
-    def delete(
-        cls,
-        items: SqlaTable | list[SqlaTable],
-        commit: bool = True,
-    ) -> None:
-        """
-        Delete the specified items(s) including their associated relationships.
-
-        Note that bulk deletion via `delete` does not dispatch the `after_delete` event
-        and thus the ORM event listener callback needs to be invoked manually.
-
-        :param items: The item(s) to delete
-        :param commit: Whether to commit the transaction
-        :raises DAODeleteFailedError: If the deletion failed
-        :see: https://docs.sqlalchemy.org/en/latest/orm/queryguide/dml.html
-        """
-
-        try:
-            db.session.query(SqlaTable).filter(
-                SqlaTable.id.in_(item.id for item in get_iterable(items))
-            ).delete(synchronize_session="fetch")
-
-            connection = db.session.connection()
-            mapper = next(iter(cls.model_cls.registry.mappers))  # type: ignore
-
-            for item in get_iterable(items):
-                security_manager.dataset_after_delete(mapper, connection, item)

Review Comment:
   yes, when doing singular deletes this is triggered via this listener: https://github.com/apache/superset/blob/master/superset/connectors/sqla/models.py#L1585.  The logic was only there since this was not triggered via the bulk delete method



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286376208


##########
superset/daos/chart.py:
##########
@@ -41,16 +41,14 @@ class ChartDAO(BaseDAO[Slice]):
 
     @classmethod
     def delete(cls, items: Slice | list[Slice], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   @jfrag1 the reason this logic is required is because `ON DELETE CASCADE` isn't configured. The right solution would be (in a separate PR) to replicate the logic outlined in https://github.com/apache/superset/pull/24628 for the `dashboard_slices` table.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] jfrag1 commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "jfrag1 (via GitHub)" <gi...@apache.org>.
jfrag1 commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286156082


##########
superset/daos/dataset.py:
##########
@@ -360,42 +359,6 @@ def create_metric(
         """
         return DatasetMetricDAO.create(properties, commit=commit)
 
-    @classmethod
-    def delete(
-        cls,
-        items: SqlaTable | list[SqlaTable],
-        commit: bool = True,
-    ) -> None:
-        """
-        Delete the specified items(s) including their associated relationships.
-
-        Note that bulk deletion via `delete` does not dispatch the `after_delete` event
-        and thus the ORM event listener callback needs to be invoked manually.
-
-        :param items: The item(s) to delete
-        :param commit: Whether to commit the transaction
-        :raises DAODeleteFailedError: If the deletion failed
-        :see: https://docs.sqlalchemy.org/en/latest/orm/queryguide/dml.html
-        """
-
-        try:
-            db.session.query(SqlaTable).filter(
-                SqlaTable.id.in_(item.id for item in get_iterable(items))
-            ).delete(synchronize_session="fetch")
-
-            connection = db.session.connection()
-            mapper = next(iter(cls.model_cls.registry.mappers))  # type: ignore
-
-            for item in get_iterable(items):

Review Comment:
   There are other custom `after_delete` listeners we'd like to trigger outside of just `security_manager.dataset_after_delete`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] jfrag1 commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "jfrag1 (via GitHub)" <gi...@apache.org>.
jfrag1 commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286152715


##########
superset/daos/chart.py:
##########
@@ -41,16 +41,14 @@ class ChartDAO(BaseDAO[Slice]):
 
     @classmethod
     def delete(cls, items: Slice | list[Slice], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   I didn't do this here because of this logic which is specific to charts:
   ```
   for item in get_iterable(items):
       item.dashboards = []
       db.session.merge(item)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] john-bodley commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "john-bodley (via GitHub)" <gi...@apache.org>.
john-bodley commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1289224525


##########
superset/daos/chart.py:
##########
@@ -41,16 +41,14 @@ class ChartDAO(BaseDAO[Slice]):
 
     @classmethod
     def delete(cls, items: Slice | list[Slice], commit: bool = True) -> None:
-        item_ids = [item.id for item in get_iterable(items)]

Review Comment:
   @jfrag1 I authored https://github.com/apache/superset/pull/24938 and https://github.com/apache/superset/pull/24939 which should aid with my suggestion above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zephyring commented on a diff in pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "zephyring (via GitHub)" <gi...@apache.org>.
zephyring commented on code in PR #24894:
URL: https://github.com/apache/superset/pull/24894#discussion_r1286158038


##########
superset/daos/dataset.py:
##########
@@ -360,42 +359,6 @@ def create_metric(
         """
         return DatasetMetricDAO.create(properties, commit=commit)
 
-    @classmethod
-    def delete(
-        cls,
-        items: SqlaTable | list[SqlaTable],
-        commit: bool = True,
-    ) -> None:
-        """
-        Delete the specified items(s) including their associated relationships.
-
-        Note that bulk deletion via `delete` does not dispatch the `after_delete` event
-        and thus the ORM event listener callback needs to be invoked manually.
-
-        :param items: The item(s) to delete
-        :param commit: Whether to commit the transaction
-        :raises DAODeleteFailedError: If the deletion failed
-        :see: https://docs.sqlalchemy.org/en/latest/orm/queryguide/dml.html
-        """
-
-        try:
-            db.session.query(SqlaTable).filter(
-                SqlaTable.id.in_(item.id for item in get_iterable(items))
-            ).delete(synchronize_session="fetch")
-
-            connection = db.session.connection()
-            mapper = next(iter(cls.model_cls.registry.mappers))  # type: ignore
-
-            for item in get_iterable(items):
-                security_manager.dataset_after_delete(mapper, connection, item)

Review Comment:
   this logic is still valid to be removed?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] codecov[bot] commented on pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #24894:
URL: https://github.com/apache/superset/pull/24894#issuecomment-1666297747

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/24894?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   > Merging [#24894](https://app.codecov.io/gh/apache/superset/pull/24894?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (c5e3f18) into [master](https://app.codecov.io/gh/apache/superset/commit/7397ab36f2872a709a5219e5318bd79aacb89930?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (7397ab3) will **decrease** coverage by `10.64%`.
   > The diff coverage is `0.00%`.
   
   > :exclamation: Current head c5e3f18 differs from pull request most recent head b295654. Consider uploading reports for the commit b295654 to get more accurate results
   
   ```diff
   @@             Coverage Diff             @@
   ##           master   #24894       +/-   ##
   ===========================================
   - Coverage   68.96%   58.33%   -10.64%     
   ===========================================
     Files        1906     1906               
     Lines       74122    74119        -3     
     Branches     8208     8208               
   ===========================================
   - Hits        51116    43235     -7881     
   - Misses      20883    28761     +7878     
     Partials     2123     2123               
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | hive | `?` | |
   | mysql | `?` | |
   | presto | `54.07% <0.00%> (+<0.01%)` | :arrow_up: |
   | python | `61.05% <0.00%> (-22.25%)` | :arrow_down: |
   | sqlite | `?` | |
   | unit | `55.05% <0.00%> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files Changed](https://app.codecov.io/gh/apache/superset/pull/24894?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [superset/daos/chart.py](https://app.codecov.io/gh/apache/superset/pull/24894?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGFvcy9jaGFydC5weQ==) | `67.27% <0.00%> (-25.46%)` | :arrow_down: |
   | [superset/daos/dashboard.py](https://app.codecov.io/gh/apache/superset/pull/24894?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGFvcy9kYXNoYm9hcmQucHk=) | `35.54% <0.00%> (-61.14%)` | :arrow_down: |
   | [superset/daos/dataset.py](https://app.codecov.io/gh/apache/superset/pull/24894?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGFvcy9kYXRhc2V0LnB5) | `51.12% <0.00%> (-40.05%)` | :arrow_down: |
   
   ... and [289 files with indirect coverage changes](https://app.codecov.io/gh/apache/superset/pull/24894/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] eschutho merged pull request #24894: chore: Update DAOs to use singular deletion method instead of bulk

Posted by "eschutho (via GitHub)" <gi...@apache.org>.
eschutho merged PR #24894:
URL: https://github.com/apache/superset/pull/24894


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org