Skip to content

[SPARK-7656] [SQL] use CatalystConf in FunctionRegistry #6164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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