Skip to content

Commit cf36cdb

Browse files
committed
[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. (cherry picked from commit fa13301) Signed-off-by: Cheng Lian <lian@databricks.com>
1 parent 51fc152 commit cf36cdb

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) with Logging {
412412
// Note that HiveUDFs will be overridden by functions registered in this context.
413413
@transient
414414
override protected[sql] lazy val functionRegistry: FunctionRegistry =
415-
new HiveFunctionRegistry(FunctionRegistry.builtin, this)
415+
new HiveFunctionRegistry(FunctionRegistry.builtin, this.executionHive)
416416

417417
/* An analyzer that uses the Hive metastore. */
418418
@transient

sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUDFs.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,19 @@ import org.apache.spark.sql.catalyst.expressions.codegen.CodegenFallback
4141
import org.apache.spark.sql.catalyst.plans.logical._
4242
import org.apache.spark.sql.catalyst.rules.Rule
4343
import org.apache.spark.sql.hive.HiveShim._
44+
import org.apache.spark.sql.hive.client.ClientWrapper
4445
import org.apache.spark.sql.types._
4546

4647

4748
private[hive] class HiveFunctionRegistry(
4849
underlying: analysis.FunctionRegistry,
49-
hiveContext: HiveContext)
50+
executionHive: ClientWrapper)
5051
extends analysis.FunctionRegistry with HiveInspectors {
5152

5253
def getFunctionInfo(name: String): FunctionInfo = {
53-
hiveContext.executionHive.withHiveState {
54+
// Hive Registry need current database to lookup function
55+
// TODO: the current database of executionHive should be consistent with metadataHive
56+
executionHive.withHiveState {
5457
FunctionRegistry.getFunctionInfo(name)
5558
}
5659
}

0 commit comments

Comments
 (0)