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


##########
superset/sql/parse.py:
##########
@@ -1371,6 +1398,31 @@ def is_mutating(self) -> bool:
 
         return False
 
+    def get_client_file_transfer_command(self) -> str | None:
+        """
+        Return the client-side file-transfer command head, if this is one.
+
+        :return: The uppercased command head (e.g. ``"PUT"``), else ``None``.
+        """
+        # sqlglot models only the quoted-path forms structurally
+        # (``PUT 'file://...' @s`` -> ``exp.Put``, whose ``key`` is the head
+        # lowercased); every other form falls back to an opaque 
``exp.Command``.
+        head = (
+            self._parsed.key.upper()
+            if isinstance(self._parsed, (exp.Put, exp.Get))
+            else self._command_head()
+        )
+        if head in self._CLIENT_FILE_TRANSFER_COMMAND_NAMES:
+            return head
+        # A nested body executes for real yet is invisible to the head match
+        # above, so it is scanned as raw text, as `changes_search_path` does
+        # for its own forms.
+        if (body := self._nested_body_text()) and (
+            match := self._CLIENT_FILE_TRANSFER_NESTED_BODY_RE.search(body)
+        ):
+            return match.group(1).upper()

Review Comment:
   <!-- Bito Reply -->
   The fix correctly addresses the issue by stripping comments and string 
literals from the nested body before scanning. This prevents false positives 
where commented-out code or string literals containing keywords were 
incorrectly flagged as client file transfer commands, while preserving the 
necessary context for dynamic SQL execution.
   
   **superset/sql/parse.py**
   ```
   if (body := self._nested_body_text()) and (
               match := self._CLIENT_FILE_TRANSFER_NESTED_BODY_RE.search(body)
           ):
               return match.group(1).upper()
   ```



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