Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -126,7 +126,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 @@ -330,7 +330,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