linhongliu-db opened a new pull request #34546:
URL: https://github.com/apache/spark/pull/34546
### What changes were proposed in this pull request?
This PR uses `AnalysisContext` to track the referred temp functions in order
to fix a temp
function resolution issue when it's registered with a `FunctionBuilder` and
referred by a temp view.
During temporary view creation, we need to collect all the temp functions
and save them
to the metadata. So that next time when resolving the view SQL text, the
functions can be
resolved correctly. But if the temp function is registered with a
`FunctionBuilder`, it's not a
`UserDefinedExpression` so it cannot be collected as a temp function. As a
result, the next time
when the analyzer resolves a temp view, the registered function couldn't be
found.
Example:
```scala
val func = CatalogFunction(FunctionIdentifier("tempFunc", None), ...)
val builder = (e: Seq[Expression]) => e.head
spark.sessionState.catalog.registerFunction(func, Some(builder))
sql("create temp view tv as select temp1(a, b) from values (1, 2) t(a, b)")
sql("select * from tv").collect()
```
### Why are the changes needed?
bug-fix
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
newly added test cases.
--
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]