bito-code-review[bot] commented on code in PR #33895:
URL: https://github.com/apache/superset/pull/33895#discussion_r3424022921


##########
superset/datasets/api.py:
##########
@@ -307,6 +312,32 @@ class DatasetRestApi(BaseSupersetModelRestApi):
     list_outer_default_load = True
     show_outer_default_load = True
 
+    def _handle_filters_args(self, rison_args: dict[str, Any]) -> Filters:
+        """
+        Handle filters arguments passed to the API endpoint.
+
+        Parses and applies filtering criteria provided as Rison-encoded 
arguments
+        to construct a Filters instance. This method ensures that each request
+        uses an isolated Filters instance to avoid shared state issues
+        in concurrent or asynchronous environments.
+
+        Example input:
+            rison_args = {
+                "filters": [
+                    {"col": "table_name", "opr": "eq", "value": "some_table"}
+                ]
+            }
+
+        :param rison_args: A dictionary of arguments parsed from the API
+                           request's Rison-encoded `q` parameter.
+        :returns: A Filters instance containing the applied filters.
+        """
+        filters = self.datamodel.get_filters(
+            search_columns=self.search_columns, 
search_filters=self.search_filters
+        )
+        filters.rest_add_filters(rison_args.get(API_FILTERS_RIS_KEY, []))
+        return filters.get_joined_filters(self._base_filters)

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>SEMANTIC_DUPLICATION: Redundant method override</b></div>
   <div id="fix">
   
   The `_handle_filters_args` method in `DatasetRestApi` is semantically 
identical to the same method already defined in the parent 
`BaseSupersetModelRestApi` (base_api.py:381-408). The test file explicitly 
documents that 'the fix lives on `BaseSupersetModelRestApi`' so every subclass 
inherits it. This override creates maintenance burden and divergence risk 
without adding any value.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```
    --- a/superset/datasets/api.py
    +++ b/superset/datasets/api.py
    @@ -26,12 +26,7 @@
     from flask import request, Response, send_file
     from flask_appbuilder.api import expose, protect, rison as parse_rison, 
safe
     from flask_appbuilder.api.schemas import get_item_schema
    -from flask_appbuilder.const import (
    -    API_FILTERS_RIS_KEY,
    -    API_RESULT_RES_KEY,
    -    API_SELECT_COLUMNS_RIS_KEY,
    -)
    -from flask_appbuilder.models.filters import Filters
    +from flask_appbuilder.const import API_RESULT_RES_KEY, 
API_SELECT_COLUMNS_RIS_KEY
     from flask_appbuilder.models.sqla.interface import SQLAInterface
     from flask_babel import ngettext
     from jinja2.exceptions import TemplateSyntaxError
    @@ -312,31 +307,6 @@
         list_outer_default_load = True
         show_outer_default_load = True
    
    -    def _handle_filters_args(self, rison_args: dict[str, Any]) -> Filters:
    -        """
    -        Handle filters arguments passed to the API endpoint.
    -
    -        Parses and applies filtering criteria provided as Rison-encoded 
arguments
    -        to construct a Filters instance. This method ensures that each 
request
    -        uses an isolated Filters instance to avoid shared state issues
    -        in concurrent or asynchronous environments.
    -
    -        Example input:
    -            rison_args = {
    -                "filters": [
    -                    {"col": "table_name", "opr": "eq", "value": 
"some_table"}
    -                ]
    -            }
    -
    -        :param rison_args: A dictionary of arguments parsed from the API
    -                           request's Rison-encoded `q` parameter.
    -        :returns: A Filters instance containing the applied filters.
    -        """
    -        filters = self.datamodel.get_filters(
    -            search_columns=self.search_columns, 
search_filters=self.search_filters
    -        )
    -        filters.rest_add_filters(rison_args.get(API_FILTERS_RIS_KEY, []))
    -        return filters.get_joined_filters(self._base_filters)
    -
         @expose("/", methods=("POST",))
         @protect()
         @safe
   ```
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #8d60e4</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to