Skip to content

Commit

Permalink
address michael's comment
Browse files Browse the repository at this point in the history
  • Loading branch information
scwf committed May 8, 2015
1 parent af512c7 commit d4b724f
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,8 @@

package org.apache.spark.sql.catalyst

import scala.collection.immutable

private[spark] object CatalystConf{
val CASE_SENSITIVE = "spark.sql.caseSensitive"
}

private[spark] trait CatalystConf {
def caseSensitiveAnalysis: Boolean
def setConf(key: String, value: String) : Unit
def getConf(key: String) : String
def getConf(key: String, defaultValue: String) : String
def getAllConfs: immutable.Map[String, String]
}

/**
Expand All @@ -39,20 +29,7 @@ object EmptyConf extends CatalystConf {
override def caseSensitiveAnalysis: Boolean = {
throw new UnsupportedOperationException
}

override def setConf(key: String, value: String) : Unit = {
throw new UnsupportedOperationException
}

override def getConf(key: String) : String = {
throw new UnsupportedOperationException
}

override def getConf(key: String, defaultValue: String) : String = {
throw new UnsupportedOperationException
}

override def getAllConfs: immutable.Map[String, String] = {
throw new UnsupportedOperationException
}
}

/** A CatalystConf that can be used for local testing. */
case class SimpleCatalystConf(caseSensitiveAnalysis: Boolean) extends CatalystConf
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ package org.apache.spark.sql.catalyst.analysis
import scala.collection.mutable.ArrayBuffer

import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.catalyst.CatalystConf
import org.apache.spark.sql.catalyst.{SimpleCatalystConf, CatalystConf}
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.catalyst.rules._
import org.apache.spark.sql.catalyst.test.SimpleCatalystConf
import org.apache.spark.sql.types._
import org.apache.spark.util.collection.OpenHashSet

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import org.apache.spark.sql.AnalysisException
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.plans.logical._
import org.apache.spark.sql.types._
import org.apache.spark.sql.catalyst.CatalystConf
import org.apache.spark.sql.catalyst.test.SimpleCatalystConf
import org.apache.spark.sql.catalyst.SimpleCatalystConf
import org.apache.spark.sql.catalyst.dsl.expressions._
import org.apache.spark.sql.catalyst.dsl.plans._

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import org.scalatest.{BeforeAndAfter, FunSuite}

import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.plans.logical.{Union, Project, LocalRelation}
import org.apache.spark.sql.catalyst.test.SimpleCatalystConf
import org.apache.spark.sql.types._
import org.apache.spark.sql.catalyst.SimpleCatalystConf

class DecimalPrecisionSuite extends FunSuite with BeforeAndAfter {
val conf = new SimpleCatalystConf(true)
Expand Down
3 changes: 2 additions & 1 deletion sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ private[spark] object SQLConf {
val CODEGEN_ENABLED = "spark.sql.codegen"
val UNSAFE_ENABLED = "spark.sql.unsafe.enabled"
val DIALECT = "spark.sql.dialect"
val CASE_SENSITIVE = "spark.sql.caseSensitive"

val PARQUET_BINARY_AS_STRING = "spark.sql.parquet.binaryAsString"
val PARQUET_INT96_AS_TIMESTAMP = "spark.sql.parquet.int96AsTimestamp"
Expand Down Expand Up @@ -164,7 +165,7 @@ private[sql] class SQLConf extends Serializable with CatalystConf {
/**
* caseSensitive analysis true by default
*/
def caseSensitiveAnalysis: Boolean = getConf(CatalystConf.CASE_SENSITIVE, "true").toBoolean
def caseSensitiveAnalysis: Boolean = getConf(SQLConf.CASE_SENSITIVE, "true").toBoolean

/**
* When set to true, Spark SQL will use managed memory for certain operations. This option only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1279,12 +1279,12 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
}

test("SPARK-4699 case sensitivity SQL query") {
setConf(CatalystConf.CASE_SENSITIVE, "false")
setConf(SQLConf.CASE_SENSITIVE, "false")
val data = TestData(1, "val_1") :: TestData(2, "val_2") :: Nil
val rdd = sparkContext.parallelize((0 to 1).map(i => data(i)))
rdd.toDF().registerTempTable("testTable1")
checkAnswer(sql("SELECT VALUE FROM TESTTABLE1 where KEY = 1"), Row("val_1"))
setConf(CatalystConf.CASE_SENSITIVE, "true")
setConf(SQLConf.CASE_SENSITIVE, "true")
}

test("SPARK-6145: ORDER BY test for nested fields") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ abstract class DataSourceTest extends QueryTest with BeforeAndAfter {
// We want to test some edge cases.
implicit val caseInsensisitiveContext = new SQLContext(TestSQLContext.sparkContext)

caseInsensisitiveContext.setConf(CatalystConf.CASE_SENSITIVE, "false")
caseInsensisitiveContext.setConf(SQLConf.CASE_SENSITIVE, "false")
}
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
protected[sql] override lazy val conf: SQLConf = new SQLConf {
override def dialect: String = getConf(SQLConf.DIALECT, "hiveql")
override def caseSensitiveAnalysis: Boolean =
getConf(CatalystConf.CASE_SENSITIVE, "false").toBoolean
getConf(SQLConf.CASE_SENSITIVE, "false").toBoolean
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class TestHiveContext(sc: SparkContext) extends HiveContext(sc) {
// The super.getConf(SQLConf.DIALECT) is "sql" by default, we need to set it as "hiveql"
override def dialect: String = super.getConf(SQLConf.DIALECT, "hiveql")
override def caseSensitiveAnalysis: Boolean =
getConf(CatalystConf.CASE_SENSITIVE, "false").toBoolean
getConf(SQLConf.CASE_SENSITIVE, "false").toBoolean
}
}

Expand Down

0 comments on commit d4b724f

Please sign in to comment.