Skip to content
Snippets Groups Projects
Commit fa13301a authored by Cheng Lian's avatar Cheng Lian
Browse files

[SPARK-11191][SQL][FOLLOW-UP] Cleans up unnecessary anonymous HiveFunctionRegistry

According to discussion in PR #9664, the anonymous `HiveFunctionRegistry` in `HiveContext` can be removed now.

Author: Cheng Lian <lian@databricks.com>

Closes #9737 from liancheng/spark-11191.follow-up.
parent d79d8b08
No related branches found
No related tags found
No related merge requests found
......@@ -454,15 +454,7 @@ class HiveContext private[hive](
// Note that HiveUDFs will be overridden by functions registered in this context.
@transient
override protected[sql] lazy val functionRegistry: FunctionRegistry =
new HiveFunctionRegistry(FunctionRegistry.builtin.copy(), this) {
override def lookupFunction(name: String, children: Seq[Expression]): Expression = {
// Hive Registry need current database to lookup function
// TODO: the current database of executionHive should be consistent with metadataHive
executionHive.withHiveState {
super.lookupFunction(name, children)
}
}
}
new HiveFunctionRegistry(FunctionRegistry.builtin.copy(), this.executionHive)
// The Hive UDF current_database() is foldable, will be evaluated by optimizer, but the optimizer
// can't access the SessionState of metadataHive.
......
......@@ -43,16 +43,19 @@ import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.rules.Rule
import org.apache.spark.sql.catalyst.util.ArrayData
import org.apache.spark.sql.hive.HiveShim._
import org.apache.spark.sql.hive.client.ClientWrapper
import org.apache.spark.sql.types._
private[hive] class HiveFunctionRegistry(
underlying: analysis.FunctionRegistry,
hiveContext: HiveContext)
executionHive: ClientWrapper)
extends analysis.FunctionRegistry with HiveInspectors {
def getFunctionInfo(name: String): FunctionInfo = {
hiveContext.executionHive.withHiveState {
// Hive Registry need current database to lookup function
// TODO: the current database of executionHive should be consistent with metadataHive
executionHive.withHiveState {
FunctionRegistry.getFunctionInfo(name)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment