Skip to content

Commit

Permalink
[SPARK-8883][SQL]Remove the OverrideFunctionRegistry
Browse files Browse the repository at this point in the history
Remove the `OverrideFunctionRegistry` from the Spark SQL, as the subclasses of `FunctionRegistry` have their own way to the delegate to the right underlying `FunctionRegistry`.

Author: Cheng Hao <hao.cheng@intel.com>

Closes #7260 from chenghao-intel/override and squashes the following commits:

164d093 [Cheng Hao] enable the function registry
2ca8459 [Cheng Hao] remove the OverrideFunctionRegistry
  • Loading branch information
chenghao-intel authored and rxin committed Jul 8, 2015
1 parent 08192a1 commit 351a36d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ trait FunctionRegistry {
def lookupFunction(name: String, children: Seq[Expression]): Expression
}

class OverrideFunctionRegistry(underlying: FunctionRegistry) extends FunctionRegistry {

private val functionBuilders = StringKeyHashMap[FunctionBuilder](caseSensitive = false)

override def registerFunction(name: String, builder: FunctionBuilder): Unit = {
functionBuilders.put(name, builder)
}

override def lookupFunction(name: String, children: Seq[Expression]): Expression = {
functionBuilders.get(name).map(_(children)).getOrElse(underlying.lookupFunction(name, children))
}
}

class SimpleFunctionRegistry extends FunctionRegistry {

private val functionBuilders = StringKeyHashMap[FunctionBuilder](caseSensitive = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ class SQLContext(@transient val sparkContext: SparkContext)

// TODO how to handle the temp function per user session?
@transient
protected[sql] lazy val functionRegistry: FunctionRegistry =
new OverrideFunctionRegistry(FunctionRegistry.builtin)
protected[sql] lazy val functionRegistry: FunctionRegistry = FunctionRegistry.builtin

@transient
protected[sql] lazy val analyzer: Analyzer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
// Note that HiveUDFs will be overridden by functions registered in this context.
@transient
override protected[sql] lazy val functionRegistry: FunctionRegistry =
new OverrideFunctionRegistry(new HiveFunctionRegistry(FunctionRegistry.builtin))
new HiveFunctionRegistry(FunctionRegistry.builtin)

/* An analyzer that uses the Hive metastore. */
@transient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private[hive] class HiveFunctionRegistry(underlying: analysis.FunctionRegistry)
}

override def registerFunction(name: String, builder: FunctionBuilder): Unit =
throw new UnsupportedOperationException
underlying.registerFunction(name, builder)
}

private[hive] case class HiveSimpleUDF(funcWrapper: HiveFunctionWrapper, children: Seq[Expression])
Expand Down

0 comments on commit 351a36d

Please sign in to comment.