Skip to content

Commit

Permalink
[SPARK-7656] [SQL] use CatalystConf in FunctionRegistry
Browse files Browse the repository at this point in the history
follow up for apache#5806

Author: scwf <[email protected]>

Closes apache#6164 from scwf/FunctionRegistry and squashes the following commits:

15e6697 [scwf] use catalogconf in FunctionRegistry
  • Loading branch information
scwf authored and marmbrus committed May 20, 2015
1 parent 3860520 commit 60336e3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.spark.sql.catalyst.analysis

import org.apache.spark.sql.catalyst.CatalystConf
import org.apache.spark.sql.catalyst.expressions.Expression
import scala.collection.mutable

Expand All @@ -28,12 +29,12 @@ trait FunctionRegistry {

def lookupFunction(name: String, children: Seq[Expression]): Expression

def caseSensitive: Boolean
def conf: CatalystConf
}

trait OverrideFunctionRegistry extends FunctionRegistry {

val functionBuilders = StringKeyHashMap[FunctionBuilder](caseSensitive)
val functionBuilders = StringKeyHashMap[FunctionBuilder](conf.caseSensitiveAnalysis)

override def registerFunction(name: String, builder: FunctionBuilder): Unit = {
functionBuilders.put(name, builder)
Expand All @@ -44,8 +45,9 @@ trait OverrideFunctionRegistry extends FunctionRegistry {
}
}

class SimpleFunctionRegistry(val caseSensitive: Boolean) extends FunctionRegistry {
val functionBuilders = StringKeyHashMap[FunctionBuilder](caseSensitive)
class SimpleFunctionRegistry(val conf: CatalystConf) extends FunctionRegistry {

val functionBuilders = StringKeyHashMap[FunctionBuilder](conf.caseSensitiveAnalysis)

override def registerFunction(name: String, builder: FunctionBuilder): Unit = {
functionBuilders.put(name, builder)
Expand All @@ -69,7 +71,7 @@ object EmptyFunctionRegistry extends FunctionRegistry {
throw new UnsupportedOperationException
}

override def caseSensitive: Boolean = throw new UnsupportedOperationException
override def conf: CatalystConf = throw new UnsupportedOperationException
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,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 SimpleFunctionRegistry(true)
protected[sql] lazy val functionRegistry: FunctionRegistry = new SimpleFunctionRegistry(conf)

@transient
protected[sql] lazy val analyzer: Analyzer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
@transient
override protected[sql] lazy val functionRegistry =
new HiveFunctionRegistry with OverrideFunctionRegistry {
def caseSensitive: Boolean = false
override def conf: CatalystConf = currentSession().conf
}

/* An analyzer that uses the Hive metastore. */
Expand Down

0 comments on commit 60336e3

Please sign in to comment.