Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Address code review comments
  • Loading branch information
shivaram committed Dec 18, 2016
commit f7b4772a4b72c28047afb7d614e3af3317af896d
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ private[sql] class SQLConf extends Serializable with CatalystConf with Logging {
def variableSubstituteDepth: Int = getConf(VARIABLE_SUBSTITUTE_DEPTH)

def warehousePath: String = {
if (contains(StaticSQLConf.WAREHOUSE_PATH.key)) {
if (contains(StaticSQLConf.WAREHOUSE_PATH.key) &&
getConf(StaticSQLConf.WAREHOUSE_PATH).isDefined) {
new Path(getConf(StaticSQLConf.WAREHOUSE_PATH).get).toString
} else {
new Path(getConf(StaticSQLConf.DEFAULT_WAREHOUSE_PATH)).toString
Expand Down Expand Up @@ -971,6 +972,7 @@ object StaticSQLConf {
}

val DEFAULT_WAREHOUSE_PATH = buildConf("spark.sql.default.warehouse.dir")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make it internal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with this part of the code base - What are the consequences of making it internal ? Is it just in terms of what shows up in documentation or does it affect how users can use it ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the internal configuration, it will not be printed out. For example, you can try something like

spark.sql("SET -v").show(numRows = 200, truncate = false)

.internal()
.doc("Default location used for managed databases and tables " +
"if spark.sql.warehouse.dir is not set")
.stringConf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,60 @@ class SQLConfSuite extends QueryTest with SharedSQLContext {
}

test("changing default value of warehouse path") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, this test case only cover one of four cases. spark.sql.default.warehouse.dir is set and spark.sql.warehouse.dir is not set. We also need to check the other three cases:

  • spark.sql.default.warehouse.dir is not set and spark.sql.warehouse.dir is not set
  • spark.sql.default.warehouse.dir is set and spark.sql.warehouse.dir is set
  • spark.sql.default.warehouse.dir is not set and spark.sql.warehouse.dir is set

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Added tests for all 4 cases now

// Set sql.default.warehouse.dir but not sql.warehouse.dir
try {
val newWarehouseDefault = "spark-warehouse2"
val newWarehouseDefaultPath = new Path(Utils.resolveURI(newWarehouseDefault)).toString
sparkContext.conf.set("spark.sql.default.warehouse.dir", newWarehouseDefaultPath)
val spark = new SparkSession(sparkContext)
assert(newWarehouseDefaultPath.stripSuffix("/") === spark
.sessionState.conf.warehousePath.stripSuffix("/"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need a check for spark.sharedState.warehousePath because we did the logic changes there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

assert(newWarehouseDefaultPath.stripSuffix("/") === spark
.sharedState.warehousePath.stripSuffix("/"))
} finally {
sparkContext.conf.remove("spark.sql.default.warehouse.dir")
}

// Set sql.warehouse.dir and sql.default.warehouse.dir. The first one should be used
try {
val newWarehouseDefault = "spark-warehouse2"
val newWarehouseDefaultPath = new Path(Utils.resolveURI(newWarehouseDefault)).toString
sparkContext.conf.set("spark.sql.default.warehouse.dir", newWarehouseDefaultPath)

val newWarehouse = "spark-warehouse3"
val newWarehousePath = new Path(Utils.resolveURI(newWarehouse)).toString
sparkContext.conf.set("spark.sql.warehouse.dir", newWarehousePath)
val spark = new SparkSession(sparkContext)
assert(newWarehousePath.stripSuffix("/") === spark
.sessionState.conf.warehousePath.stripSuffix("/"))
assert(newWarehousePath.stripSuffix("/") === spark
.sharedState.warehousePath.stripSuffix("/"))
} finally {
sparkContext.conf.remove("spark.sql.default.warehouse.dir")
sparkContext.conf.remove("spark.sql.warehouse.dir")
}

// Set sql.warehouse.dir but not sql.default.warehouse.dir
try {
val newWarehouse = "spark-warehouse4"
val newWarehousePath = new Path(Utils.resolveURI(newWarehouse)).toString
sparkContext.conf.set("spark.sql.warehouse.dir", newWarehousePath)
val spark = new SparkSession(sparkContext)
assert(newWarehousePath.stripSuffix("/") === spark
.sessionState.conf.warehousePath.stripSuffix("/"))
assert(newWarehousePath.stripSuffix("/") === spark
.sharedState.warehousePath.stripSuffix("/"))
} finally {
sparkContext.conf.remove("spark.sql.warehouse.dir")
}

// Set neither of the two configs. The default value should be "spark-warehouse"

val spark = new SparkSession(sparkContext)
assert(new Path(Utils.resolveURI("spark-warehouse")).toString.stripSuffix("/") === spark
.sessionState.conf.warehousePath.stripSuffix("/"))
assert(new Path(Utils.resolveURI("spark-warehouse")).toString.stripSuffix("/") === spark
.sharedState.warehousePath.stripSuffix("/"))
}

test("MAX_CASES_BRANCHES") {
Expand Down