Github user viirya commented on the issue:
https://github.com/apache/spark/pull/20795
I've added a test like this:
```scala
class LookupFunctionsSuite extends PlanTest {
test("SPARK-23486: LookupFunctions should not check the same function
name more than once") {
val externalCatalog = new CustomInMemoryCatalog
val analyzer = {
val conf = new SQLConf()
val catalog = new SessionCatalog(externalCatalog,
FunctionRegistry.builtin, conf)
catalog.createDatabase(
CatalogDatabase("default", "", new URI("loc"), Map.empty),
ignoreIfExists = false)
new Analyzer(catalog, conf)
}
val unresolvedFunc = UnresolvedFunction("func", Seq.empty, false)
val plan = Project(
Seq(Alias(unresolvedFunc, "call1")(), Alias(unresolvedFunc,
"call2")()),
table("TaBlE"))
analyzer.LookupFunctions.apply(plan)
assert(externalCatalog.getFunctionExistsCalledTimes == 1)
}
}
class CustomInMemoryCatalog extends InMemoryCatalog {
private var functionExistsCalledTimes: Int = 0
override def functionExists(db: String, funcName: String): Boolean =
synchronized {
functionExistsCalledTimes = functionExistsCalledTimes + 1
true
}
def getFunctionExistsCalledTimes: Int = functionExistsCalledTimes
}
```
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]