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


##########
superset/commands/chart/data/streaming_export_command.py:
##########
@@ -66,12 +90,22 @@ 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())
-        database = getattr(datasource, "database", None)
-        catalog = getattr(datasource, "catalog", None)
-        schema = getattr(datasource, "schema", None)
+        if (
+            not isinstance(datasource, _SQLDatasource)
+            or not callable(datasource.get_query_str_extended)
+            or datasource.database is None
+        ):
+            raise QueryObjectValidationError(
+                _("Streaming CSV export requires a SQL datasource")
+            )
+        database = datasource.database
+        sql_query = datasource.get_query_str_extended(query_obj.to_dict()).sql

Review Comment:
   **Suggestion:** Add an explicit variable type annotation for this local SQL 
assignment so the new code fully complies with required type hints. 
[custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   This is a newly added local variable assignment in Python that can be 
annotated with a concrete type, but it is left untyped. That fits the stated 
type-hint rule for relevant variables, so the suggestion 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=8abc4ce9457545838efd58b82b9627ab&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=8abc4ce9457545838efd58b82b9627ab&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:** 102:102
   **Comment:**
        *Custom Rule: Add an explicit variable type annotation for this local 
SQL assignment so the new code fully complies with required type hints.
   
   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=2e5796a06dddb57d490ee9f3b30bc7d7013ab129edf2903a47e62e137365b2fb&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=2e5796a06dddb57d490ee9f3b30bc7d7013ab129edf2903a47e62e137365b2fb&reaction=dislike'>๐Ÿ‘Ž</a>



##########
superset/commands/chart/data/streaming_export_command.py:
##########
@@ -66,12 +90,22 @@ 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())
-        database = getattr(datasource, "database", None)
-        catalog = getattr(datasource, "catalog", None)
-        schema = getattr(datasource, "schema", None)
+        if (
+            not isinstance(datasource, _SQLDatasource)
+            or not callable(datasource.get_query_str_extended)
+            or datasource.database is None
+        ):
+            raise QueryObjectValidationError(
+                _("Streaming CSV export requires a SQL datasource")
+            )
+        database = datasource.database

Review Comment:
   **Suggestion:** Add an explicit variable type annotation for this local 
assignment to satisfy the type-hint requirement for relevant variables. 
[custom_rule]
   
   **Severity Level:** Minor ๐Ÿงน
   <details>
   <summary><b>Why it matters? โญ </b></summary>
   
   This new local assignment introduces a variable that can be explicitly 
type-annotated, and the custom rule requires type hints for relevant variables 
that can be annotated. The code currently relies on inference only, so the 
suggestion matches 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=17075d4ff9264fe196611ae8f28d640c&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=17075d4ff9264fe196611ae8f28d640c&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:** 101:101
   **Comment:**
        *Custom Rule: Add an explicit variable type annotation for this local 
assignment to satisfy the type-hint requirement for relevant 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=3ca36d25a513b1a2a2a2b1d1bf4c5820f235db5c99992042d7a16b359b5feb70&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37516&comment_hash=3ca36d25a513b1a2a2a2b1d1bf4c5820f235db5c99992042d7a16b359b5feb70&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