Skip to content

Commit d74d5e8

Browse files
viiryamarmbrus
authored andcommitted
[Minor][SQL] Use same function to check path parameter in JSONRelation
Author: Liang-Chi Hsieh <[email protected]> Closes #4649 from viirya/use_checkpath and squashes the following commits: 0f9a1a1 [Liang-Chi Hsieh] Use same function to check path parameter. (cherry picked from commit ac506b7) Signed-off-by: Michael Armbrust <[email protected]>
1 parent 62063b7 commit d74d5e8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

sql/core/src/main/scala/org/apache/spark/sql/json/JSONRelation.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private[sql] class DefaultSource
3737
override def createRelation(
3838
sqlContext: SQLContext,
3939
parameters: Map[String, String]): BaseRelation = {
40-
val path = parameters.getOrElse("path", sys.error("Option 'path' not specified"))
40+
val path = checkPath(parameters)
4141
val samplingRatio = parameters.get("samplingRatio").map(_.toDouble).getOrElse(1.0)
4242

4343
JSONRelation(path, samplingRatio, None)(sqlContext)
@@ -48,7 +48,7 @@ private[sql] class DefaultSource
4848
sqlContext: SQLContext,
4949
parameters: Map[String, String],
5050
schema: StructType): BaseRelation = {
51-
val path = parameters.getOrElse("path", sys.error("Option 'path' not specified"))
51+
val path = checkPath(parameters)
5252
val samplingRatio = parameters.get("samplingRatio").map(_.toDouble).getOrElse(1.0)
5353

5454
JSONRelation(path, samplingRatio, Some(schema))(sqlContext)

sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ class MetastoreDataSourcesSuite extends QueryTest with BeforeAndAfterEach {
547547
Map.empty[String, String])
548548
}.getMessage
549549
assert(
550-
message.contains("Option 'path' not specified"),
550+
message.contains("'path' must be specified for json data."),
551551
"We should complain that path is not specified.")
552552

553553
sql("DROP TABLE savedJsonTable")

0 commit comments

Comments
 (0)