sryza commented on code in PR #53024:
URL: https://github.com/apache/spark/pull/53024#discussion_r2524166819
##########
python/pyspark/pipelines/block_connect_access.py:
##########
@@ -24,6 +24,27 @@
BLOCKED_RPC_NAMES = ["AnalyzePlan", "ExecutePlan"]
+def _is_sql_command_request(rpc_name: str, args: tuple) -> bool:
+ """
+ Check if the RPC call is a spark.sql() command (ExecutePlan with
sql_command).
+
+ :param rpc_name: Name of the RPC being called
+ :param args: Arguments passed to the RPC
+ :return: True if this is an ExecutePlan request with a sql_command
+ """
+ if rpc_name != "ExecutePlan" or len(args) == 0:
+ return False
+
+ request = args[0]
+ if not hasattr(request, "plan"):
+ return False
+ plan = request.plan
+ if not plan.HasField("command"):
+ return False
+ command = plan.command
+ return command.HasField("sql_command")
+
+
@contextmanager
def block_spark_connect_execution_and_analysis() -> Generator[None, None,
None]:
Review Comment:
Now that we have the context on the server side, it might make more sense to
block these operations there – then we don't need to replicate this weird
monkeypatching logic across all the clients when we add support for other
languages. Doesn't need to be part of this PR though.
--
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]