Skip to content

Commit 4ede705

Browse files
committed
Throw exception instead of warning message.
1 parent 68a1c70 commit 4ede705

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/commands.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ case class SetCommand(
8585
s"Property ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS} is deprecated, " +
8686
s"automatically converted to ${SQLConf.SHUFFLE_PARTITIONS} instead.")
8787
if (value == "-1") {
88-
logWarning(
89-
s"Set this property to -1 for automatically determining the number of reducers " +
90-
s"is not supported, showing current ${SQLConf.SHUFFLE_PARTITIONS} instead.")
91-
Seq(Row(s"${SQLConf.SHUFFLE_PARTITIONS}=${sqlContext.conf.numShufflePartitions}"))
88+
val msg = s"Setting ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS} to -1 for automatically " +
89+
"determining the number of reducers is not supported."
90+
throw new IllegalArgumentException(msg)
9291
} else {
9392
sqlContext.setConf(SQLConf.SHUFFLE_PARTITIONS, value)
9493
Seq(Row(s"${SQLConf.SHUFFLE_PARTITIONS}=$value"))

sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,13 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
830830
conf.clear()
831831
}
832832

833+
test("SET commands with illegal or inappropriate argument") {
834+
conf.clear()
835+
// mapred.reduce.tasks=-1 for automatically determing the number of reducers is not supported
836+
intercept[IllegalArgumentException](sql(s"SET mapred.reduce.tasks=-1"))
837+
conf.clear()
838+
}
839+
833840
test("apply schema") {
834841
val schema1 = StructType(
835842
StructField("f1", IntegerType, false) ::

0 commit comments

Comments
 (0)