bito-code-review[bot] commented on code in PR #44496:
URL: https://github.com/apache/superset/pull/44496#discussion_r4068950285
##########
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:
<div>
<div id="suggestion">
<div id="issue"><b>Raw-body scan false positive</b></div>
<div id="fix">
The raw-body scan in `_nested_body_text()` matches inside comments and
string literals: `DO $$ BEGIN -- GET @stage ...` and `CALL p('GET @stage')`
both return `GET` (verified against the regex). The gate in
`sql_lab.py`/`executor.py` then rejects these legitimate queries as
`SupersetDisallowedClientFileTransferException`. The comment only guards the
column-name case, not comments/strings. Strip comments and string literals
before scanning.
</div>
</div>
<small><i>Code Review Run #afc705</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]