sha174n commented on code in PR #44496:
URL: https://github.com/apache/superset/pull/44496#discussion_r4069249768
##########
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:
Fixed in 9afeb83. Comments are now stripped from the nested body before any
scan (done in `_nested_body_text` so the sibling scans get the same text), so
the commented-out case no longer matches. String literals are deliberately
kept: a nested body runs its dynamic SQL out of a literal (`EXECUTE IMMEDIATE
'...'`), so dropping them would blind the scan to the form it exists to catch.
Also fixed a related miss where a body with doubled quotes was skipped.
--
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]