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


##########
superset/db_engine_specs/impala.py:
##########
@@ -147,33 +149,29 @@ def handle_cursor(cls, cursor: Any, query: Query) -> None:
                 # the query was still executed
                 # modified in stop_query in views / core.py is reflected  here.
                 # stop query
-                if query.extra.get(QUERY_EARLY_CANCEL_KEY):
+                if query.extra.get(QUERY_EARLY_CANCEL_KEY) or query.status in (
+                    QueryStatus.STOPPED,
+                    QueryStatus.TIMED_OUT,
+                ):

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag the established polling pattern that reuses the existing 
database read and then checks for STOPPED or TIMED_OUT status; keep it 
consistent with the other database engine specifications.
   
   **Applied to:**
     - `superset/db_engine_specs/impala.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



##########
superset/db_engine_specs/impala.py:
##########
@@ -147,33 +149,29 @@ def handle_cursor(cls, cursor: Any, query: Query) -> None:
                 # the query was still executed
                 # modified in stop_query in views / core.py is reflected  here.
                 # stop query
-                if query.extra.get(QUERY_EARLY_CANCEL_KEY):
+                if query.extra.get(QUERY_EARLY_CANCEL_KEY) or query.status in (
+                    QueryStatus.STOPPED,
+                    QueryStatus.TIMED_OUT,
+                ):
                     cursor.cancel_operation()
                     cursor.close_operation()
                     cursor.close()
                     break
 
-                #  updates progress info by log
-                try:
-                    log = cursor.get_log() or ""
-                except Exception:  # pylint: disable=broad-except
-                    logger.warning("Call to GetLog() failed")
-                    log = ""
+                # Pending/initialized operations have no execution progress 
yet.
+                if status == "RUNNING_STATE":
+                    try:
+                        log = cursor.get_log() or ""
+                    except Exception:  # pylint: disable=broad-except
+                        logger.warning("Call to GetLog() failed")
+                        log = ""
 
-                if log:
-                    match = QUERY_PROGRESS_REGEX.match(log)
-                    if match:
+                    if match := QUERY_PROGRESS_REGEX.match(log):
                         progress = int(match.groupdict()["query_progress"])
-                    logger.debug(
-                        "Query %s: Progress total: %s", str(query_id), 
str(progress)
-                    )
-                    needs_commit = False
-                    if progress > query.progress:
-                        query.progress = progress
-                        needs_commit = True
-
-                    if needs_commit:
-                        db.session.commit()  # pylint: 
disable=consider-using-transaction
+                        logger.debug("Query %s: Progress total: %s", query_id, 
progress)
+                        if progress > query.progress:
+                            query.progress = progress
+                            db.session.commit()  # pylint: 
disable=consider-using-transaction

Review Comment:
   ✅ **Customized review instruction saved!**
   
   **Instruction:**
   > Do not flag NULL-comparison risks for Query.progress in Impala 
cancellation polling; the ORM Integer column defaults to 0 on query creation 
and is non-null when handle_cursor runs.
   
   **Applied to:**
     - `superset/db_engine_specs/impala.py`
   
   ---
   💡 *To manage or update this instruction, visit: [CodeAnt AI 
Settings](https://app.codeant.ai/org/settings/learnings)*



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