davidm-db commented on code in PR #53530:
URL: https://github.com/apache/spark/pull/53530#discussion_r2698216913
##########
sql/core/src/main/scala/org/apache/spark/sql/scripting/SqlScriptingExecutionContext.scala:
##########
@@ -53,6 +55,108 @@ class SqlScriptingExecutionContext extends
SqlScriptingExecutionContextExtension
def currentFrame: SqlScriptingExecutionFrame = frames.last
def currentScope: SqlScriptingExecutionScope = currentFrame.currentScope
+ /**
+ * Find a cursor by its normalized name in the current scope and parent
scopes.
+ * Implementation of SqlScriptingExecutionContextExtension API.
+ *
+ * Searches current frame first (respects shadowing), then script frame (for
cross-frame access).
+ * This ensures cursors declared in handlers shadow cursors with the same
name in the script.
+ */
+ override def findCursorByName(normalizedName: String):
Option[CursorDefinition] = {
Review Comment:
I don't think example like this would work for cursors:
<img width="587" height="520" alt="image"
src="https://github.com/user-attachments/assets/a3a38780-8ed8-4f87-8383-45f1125eb70a"
/>
Specifically if `x2` was a cursor, it wouldn't get resolved because we are
searching only the last and the first frame.
I know this is a very artificial example, especially for cursors I cannot
imagine why someone would do it this way, but it is something we allow. But, my
comment is more on a level that we already have a resolution logic implemented
in the aforementioned places in code and I don't think we should duplicate it -
highlighting again that we will/might have similar types in future that should
also adhere to the same resolution logic.
--
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]