codeant-ai-for-open-source[bot] commented on code in PR #37516:
URL: https://github.com/apache/superset/pull/37516#discussion_r3571060718


##########
tests/integration_tests/charts/data/api_tests.py:
##########
@@ -834,8 +848,8 @@ def test_chart_data_post_is_cached_in_event_logger(self, 
mock_event_logger):
 
     @with_feature_flags(GLOBAL_ASYNC_QUERIES=True)
     @pytest.mark.usefixtures("load_birth_names_dashboard_with_slices")
-    @mock.patch("superset.charts.data.api.ChartDataCommand.run")
-    def test_chart_data_async_force_refresh(self, mock_run):
+    @mock.patch("superset.charts.data.api.ChartDataCommand.execute")
+    def test_chart_data_async_force_refresh(self, mock_execute):

Review Comment:
   **Suggestion:** Add explicit type hints to this newly added test method, 
including parameter and return annotations. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The rule requires type hints on new or modified Python functions/methods 
when they can be annotated. This newly added test method has no parameter 
annotations and no return type annotation, so it violates the rule.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f39d3cbdac2743e0bc1e6439920152d1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f39d3cbdac2743e0bc1e6439920152d1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/integration_tests/charts/data/api_tests.py
   **Line:** 852:852
   **Comment:**
        *Custom Rule: Add explicit type hints to this newly added test method, 
including parameter and return annotations.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=2cbe690b2596dea758140004049659e507c9786fd0851952107dcefa922d985b&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=2cbe690b2596dea758140004049659e507c9786fd0851952107dcefa922d985b&reaction=dislike'>๐Ÿ‘Ž</a>



##########
tests/integration_tests/charts/data/api_tests.py:
##########
@@ -1411,14 +1436,18 @@ def test_chart_data_cache(self, cache_loader):
         app._got_first_request = False
         async_query_manager_factory.init_app(app)
         cache_loader.load.return_value = self.query_context_payload
-        orig_run = ChartDataCommand.run
-
-        def mock_run(self, **kwargs):
-            assert kwargs["force_cached"] is True  # noqa: E712
+        orig_execute = ChartDataCommand.execute
+
+        def mock_execute(
+            self: ChartDataCommand,
+            options: ChartDataExecutionOptions | None = None,
+        ):

Review Comment:
   **Suggestion:** Add a return type annotation to this newly added helper 
function so the full function signature is typed. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   This newly added helper function is partially typed but omits a return type 
annotation, which the rule explicitly requires for annotatable Python functions.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e9188b49fcaf42498cf0649bccb003fe&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=e9188b49fcaf42498cf0649bccb003fe&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** tests/integration_tests/charts/data/api_tests.py
   **Line:** 1441:1444
   **Comment:**
        *Custom Rule: Add a return type annotation to this newly added helper 
function so the full function signature is typed.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=ec729c5052ff73304df6157fb4ba75f3e1d75944ed54b4393da2e8c207aec9a3&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=ec729c5052ff73304df6157fb4ba75f3e1d75944ed54b4393da2e8c207aec9a3&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/commands/chart/data/streaming_export_command.py:
##########
@@ -66,8 +69,13 @@ def _get_sql_and_database(self) -> tuple[str, Any, str | 
None, str | None]:
         # Note: datasource should already be attached to a session from 
query_context
         datasource = self._query_context.datasource
         query_obj = self._query_context.queries[0]
-        sql_query = datasource.get_query_str(query_obj.to_dict())
+        get_query_str_extended = getattr(datasource, "get_query_str_extended", 
None)
         database = getattr(datasource, "database", None)
+        if not callable(get_query_str_extended) or database is None:
+            raise QueryObjectValidationError(
+                _("Streaming CSV export requires a SQL datasource")
+            )
+        sql_query = get_query_str_extended(query_obj.to_dict()).sql

Review Comment:
   **Suggestion:** Add explicit type annotations for the newly introduced local 
variables so the new logic complies with the type-hint requirement. 
[custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The new local variables `get_query_str_extended`, `database`, and 
`sql_query` are introduced without explicit type annotations, and they are 
straightforwardly annotatable. This matches the Python type-hint rule for newly 
added code.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0e178ffd29f343dcae85b4dc1900edbc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0e178ffd29f343dcae85b4dc1900edbc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/commands/chart/data/streaming_export_command.py
   **Line:** 72:78
   **Comment:**
        *Custom Rule: Add explicit type annotations for the newly introduced 
local variables so the new logic complies with the type-hint requirement.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=8c519f2f65e4d75385e64f47b2ed8e423406122c310766b20f21da4ac6ae3372&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=8c519f2f65e4d75385e64f47b2ed8e423406122c310766b20f21da4ac6ae3372&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/semantic_layers/mapper.py:
##########
@@ -119,14 +126,17 @@ def get_results(query_object: QueryObject) -> QueryResult:
 
     # Step 1: Convert QueryObject to list of SemanticQuery objects
     # The first query is the main query, subsequent queries are for time 
offsets
-    queries = map_query_object(query_object)
+    with source_phase("planning"):
+        queries = map_query_object(query_object)
 
     # Step 2: Execute the main query (first in the list)
     main_query = queries[0]
-    main_result = dispatcher(main_query)
+    with source_phase("execution"):
+        main_result = dispatcher(main_query)
     main_result = _coerce_empty_result(main_result, main_query)
 
-    main_df = stringify_extension_columns(main_result.results).to_pandas()
+    with source_phase("processing"):
+        main_df = stringify_extension_columns(main_result.results).to_pandas()

Review Comment:
   **Suggestion:** Add an explicit type annotation for this DataFrame variable 
to satisfy the type-hint requirement for relevant newly introduced variables. 
[custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   This is a newly introduced local variable that is clearly type-annotatable 
as a pandas DataFrame, but it is assigned without an explicit type hint, so it 
matches the Python type-hint rule.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=4ebf164d07b24dcaa88fe06d131a634e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=4ebf164d07b24dcaa88fe06d131a634e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/semantic_layers/mapper.py
   **Line:** 139:139
   **Comment:**
        *Custom Rule: Add an explicit type annotation for this DataFrame 
variable to satisfy the type-hint requirement for relevant newly introduced 
variables.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=c8fbe274e4be5aa06bb2b8bd5ecc430630775b92b68f4620903c3a814150931e&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=c8fbe274e4be5aa06bb2b8bd5ecc430630775b92b68f4620903c3a814150931e&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/charts/schemas.py:
##########
@@ -1404,6 +1410,19 @@ class Meta:  # pylint: disable=too-few-public-methods
         metadata={"description": "Columns which to select in the query."},
         allow_none=True,
     )
+    contribution_totals_query_index = fields.Integer(
+        metadata={
+            "description": "Index of the query that supplies all-record totals 
"
+            "for contribution post-processing."
+        },
+        allow_none=True,
+        validate=Range(
+            min=0,
+            error=(
+                "`contribution_totals_query_index` must be greater than or 
equal to 0"
+            ),
+        ),
+    )

Review Comment:
   **Suggestion:** Add an explicit type annotation for this newly introduced 
schema field attribute. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The custom rule requires type hints for newly added Python variables that 
can be annotated. This new class attribute is a schema field declared without 
any type annotation, so the suggestion correctly identifies a real rule 
violation.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f9124d2bfdab409a9effe012b5ac0697&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f9124d2bfdab409a9effe012b5ac0697&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/charts/schemas.py
   **Line:** 1413:1425
   **Comment:**
        *Custom Rule: Add an explicit type annotation for this newly introduced 
schema field attribute.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=38efd9a57a04b30472846068d4f28368c62af897d6a3eade88c547af014a84e4&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=38efd9a57a04b30472846068d4f28368c62af897d6a3eade88c547af014a84e4&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/charts/schemas.py:
##########
@@ -1542,6 +1561,47 @@ class AnnotationDataSchema(Schema):
     )
 
 
+class ChartDataSourceTimingSchema(Schema):
+    """Schema for one bounded source timing node."""
+
+    kind = fields.Enum(SourceKind, by_value=True, required=True)
+    provider = fields.Enum(SourceProvider, by_value=True, required=True)
+    origin = fields.Enum(SourceOrigin, by_value=True, required=True)
+    planning_ms = fields.Float(required=True)
+    execution_ms = fields.Float(required=True)
+    processing_ms = fields.Float(required=True)
+    total_ms = fields.Float(required=True)
+    children = fields.List(
+        fields.Nested(lambda: ChartDataSourceTimingSchema()), required=True
+    )
+    truncated = fields.Boolean(required=True)
+
+
+class ChartDataQueryTimingSchema(Schema):
+    """Schema for cache, source, and materialization phases."""
+
+    cache_key_ms = fields.Float(required=True)
+    cache_read_ms = fields.Float(required=True)
+    source_ms = fields.Float(required=True)

Review Comment:
   **Suggestion:** Add type annotations to the newly added query timing field 
attributes so they comply with the type-hint rule. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   These are newly added schema field attributes and they are not annotated 
with types. That fits the stated rule about omitting type hints on relevant 
variables, so the finding is valid.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=cfe435a580d84c82ba1d77baa1f63dca&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=cfe435a580d84c82ba1d77baa1f63dca&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/charts/schemas.py
   **Line:** 1583:1585
   **Comment:**
        *Custom Rule: Add type annotations to the newly added query timing 
field attributes so they comply with the type-hint rule.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=9d8e029f2e9c4f5fbe8d7b68857cd977f6da9c05dacc01051643099a784ec47b&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=9d8e029f2e9c4f5fbe8d7b68857cd977f6da9c05dacc01051643099a784ec47b&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/common/utils/query_cache_manager.py:
##########
@@ -69,12 +75,14 @@ def __init__(
         cache_value: dict[str, Any] | None = None,
         sql_rowcount: int | None = None,
         queried_dttm: str | None = None,
+        source_trace: tuple[SourceTiming, ...] | None = None,
     ) -> None:
-        self.df = df
+        self.df = DataFrame() if df is None else df
         self.query = query
         self.annotation_data = {} if annotation_data is None else 
annotation_data
         self.applied_template_filters = applied_template_filters or []
         self.applied_filter_columns = applied_filter_columns or []
+        self.has_applied_filter_columns = applied_filter_columns is not None

Review Comment:
   **Suggestion:** Add an explicit boolean instance-attribute annotation for 
this new field assignment to comply with the typing requirement. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   This new instance attribute is assigned in __init__ without an explicit type 
hint, which matches the Python type-hint rule for annotating newly added 
relevant variables and attributes.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=1b91cfe3340341d2a0a257662dd5afe8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=1b91cfe3340341d2a0a257662dd5afe8&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/common/utils/query_cache_manager.py
   **Line:** 85:85
   **Comment:**
        *Custom Rule: Add an explicit boolean instance-attribute annotation for 
this new field assignment to comply with the typing requirement.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=1e10f997835b8345d4257d09021de707369276cb1fa70e2c17fbdd5b1e804530&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=1e10f997835b8345d4257d09021de707369276cb1fa70e2c17fbdd5b1e804530&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/charts/schemas.py:
##########
@@ -1542,6 +1561,47 @@ class AnnotationDataSchema(Schema):
     )
 
 
+class ChartDataSourceTimingSchema(Schema):
+    """Schema for one bounded source timing node."""
+
+    kind = fields.Enum(SourceKind, by_value=True, required=True)
+    provider = fields.Enum(SourceProvider, by_value=True, required=True)
+    origin = fields.Enum(SourceOrigin, by_value=True, required=True)
+    planning_ms = fields.Float(required=True)
+    execution_ms = fields.Float(required=True)
+    processing_ms = fields.Float(required=True)
+    total_ms = fields.Float(required=True)

Review Comment:
   **Suggestion:** Add explicit type hints for the newly added timing schema 
attributes instead of leaving them unannotated. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   These newly introduced class attributes are plain assignments with no type 
annotations. Under the type-hint rule, such annotatable Python variables should 
be typed, so this is a real violation.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=16cc79b4a72c4a1aa10c03eaa812995c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=16cc79b4a72c4a1aa10c03eaa812995c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/charts/schemas.py
   **Line:** 1570:1573
   **Comment:**
        *Custom Rule: Add explicit type hints for the newly added timing schema 
attributes instead of leaving them unannotated.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=1c76a8205691f9d6c4c30442159dfa518ec530a3811cc8225ab0d910a88ae116&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=1c76a8205691f9d6c4c30442159dfa518ec530a3811cc8225ab0d910a88ae116&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/common/utils/query_cache_manager.py:
##########
@@ -86,6 +94,8 @@ def __init__(
         self.cache_value = cache_value
         self.sql_rowcount = sql_rowcount
         self.queried_dttm = queried_dttm
+        self.source_trace = source_trace
+        self.cache_write_outcome = CacheWriteOutcome.NOT_ATTEMPTED

Review Comment:
   **Suggestion:** Annotate this newly added instance field with its enum type 
so the cache-write status is explicitly typed. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   This newly introduced instance field is assigned without an annotation, so 
it violates the rule requiring type hints on new Python variables/attributes 
that can be annotated.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=75ef6b7114434cfba0c6242765fe8a9d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=75ef6b7114434cfba0c6242765fe8a9d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/common/utils/query_cache_manager.py
   **Line:** 98:98
   **Comment:**
        *Custom Rule: Annotate this newly added instance field with its enum 
type so the cache-write status is explicitly typed.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=6fa3b4904b2d729e09f47ce112f889f7d57237f028b914f2ebdf13f5a09a3801&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=6fa3b4904b2d729e09f47ce112f889f7d57237f028b914f2ebdf13f5a09a3801&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/common/utils/query_cache_manager.py:
##########
@@ -133,35 +163,68 @@ def set_query_result(
                 )
                 g.bq_memory_limited = False
                 g.bq_memory_limited_row_count = 0
-
-            value = {
-                "df": self.df,
-                "query": self.query,
-                "applied_template_filters": self.applied_template_filters,
-                "applied_filter_columns": self.applied_filter_columns,
-                "rejected_filter_columns": self.rejected_filter_columns,
-                "annotation_data": self.annotation_data,
-                "sql_rowcount": self.sql_rowcount,
-                "queried_dttm": self.queried_dttm,
-                "dttm": self.queried_dttm,  # Backwards compatibility
-                "bq_memory_limited": self.bq_memory_limited,
-                "bq_memory_limited_row_count": 
self.bq_memory_limited_row_count,
-            }
-            if self.is_loaded and key and self.status != QueryStatus.FAILED:
-                self.set(
-                    key=key,
-                    value=value,
-                    timeout=timeout,
-                    datasource_uid=datasource_uid,
-                    region=region,
-                )
         except Exception as ex:  # pylint: disable=broad-except
             logger.exception(ex)
             if not self.error_message:
                 self.error_message = str(ex)
             self.status = QueryStatus.FAILED
             self.stacktrace = get_stacktrace()
 
+    def write_query_result(
+        self,
+        key: str,
+        timeout: int | None = None,
+        datasource_uid: str | None = None,
+        region: CacheRegion = CacheRegion.DEFAULT,
+    ) -> bool:
+        """Compatibility wrapper returning whether the cache write 
succeeded."""
+
+        return (
+            self.write_query_result_with_outcome(
+                key=key,
+                timeout=timeout,
+                datasource_uid=datasource_uid,
+                region=region,
+            )
+            == CacheWriteOutcome.SUCCEEDED
+        )
+
+    def write_query_result_with_outcome(
+        self,
+        key: str,
+        timeout: int | None = None,
+        datasource_uid: str | None = None,
+        region: CacheRegion = CacheRegion.DEFAULT,
+    ) -> CacheWriteOutcome:
+        """Write an already loaded result and expose the typed outcome."""
+
+        if not self.is_loaded or not key or self.status == QueryStatus.FAILED:
+            self.cache_write_outcome = CacheWriteOutcome.NOT_ATTEMPTED
+            return self.cache_write_outcome
+        value = {

Review Comment:
   **Suggestion:** Add an explicit type annotation to this newly introduced 
local variable to satisfy required variable typing. [custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   The new local variable `value` is introduced without a type annotation even 
though it has a clear dictionary type, which fits the type-hint requirement.
   </details>
   <details>
   <summary><b>Rule source ๐Ÿ“– </b></summary>
   
   .cursor/rules/dev-standard.mdc (line 28)
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=0cfbb9a3a72549669dc6eb339c28829b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=0cfbb9a3a72549669dc6eb339c28829b&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   
   *(Use Cmd/Ctrl + Click for best experience)*
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/common/utils/query_cache_manager.py
   **Line:** 204:204
   **Comment:**
        *Custom Rule: Add an explicit type annotation to this newly introduced 
local variable to satisfy required variable typing.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=669a258b2e918c1cd4004adda4539058534306fec90ea1350a313a6f04d49f42&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=669a258b2e918c1cd4004adda4539058534306fec90ea1350a313a6f04d49f42&reaction=dislike'>๐Ÿ‘Ž</a>



-- 
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