dtenedor commented on code in PR #60367:
URL: https://github.com/apache/spark/pull/60367#discussion_r4620489113
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala:
##########
@@ -313,7 +332,18 @@ object AnalysisContext {
} else {
mutable.LinkedHashSet.empty
},
- collation = function.collation)
+ // The body of a SQL function is not a part of the query that calls it.
If the call is in a
Review Comment:
Fixed. `withAnalysisContext(function)` now sets the new
`AnalysisContext.isPersistentSQLFunctionBody` for a function with a database. A
database is how `SessionCatalog.registerUserDefinedFunction` tells a persistent
function from a temporary one. `VariableResolution.resolveMultipartName` then
resolves no name with a `?` to a variable, so the plain, session-qualified, and
label-qualified optional references of a persistent body stay the NULL they
were at creation, as in a persistent view. Temporary functions and names
without `?` resolve as before. The new `SQLFunctionSuite` test creates a
persistent scalar function with `coalesce(x?, 0) + coalesce(session.x?, 0)`, a
persistent table function with `x?`, and a persistent function with `lbl.x?`.
Each one returns 0 when called with a session variable `x`, with a script
variable `x`, or inside a block labeled `lbl` that declares `x`. Without the
fix, each call returned the value of the variable. A temporary function with
`x?` still ret
urns the session variable.
--
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]