Skip to content

Commit e518f96

Browse files
committed
Consider other wrong setting values.
1 parent fd9c817 commit e518f96

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ case class SetCommand(
8484
logWarning(
8585
s"Property ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS} is deprecated, " +
8686
s"automatically converted to ${SQLConf.SHUFFLE_PARTITIONS} instead.")
87-
if (value == "-1") {
88-
val msg = s"Setting ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS} to -1 for automatically " +
87+
if (value.toInt < 1) {
88+
val msg = s"Setting negative ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS} for automatically " +
8989
"determining the number of reducers is not supported."
9090
throw new IllegalArgumentException(msg)
9191
} else {

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,11 @@ class SQLQuerySuite extends QueryTest with BeforeAndAfterAll {
864864

865865
test("SET commands with illegal or inappropriate argument") {
866866
conf.clear()
867-
// mapred.reduce.tasks=-1 for automatically determing the number of reducers is not supported
867+
// Set negative mapred.reduce.tasks for automatically determing
868+
// the number of reducers is not supported
868869
intercept[IllegalArgumentException](sql(s"SET mapred.reduce.tasks=-1"))
870+
intercept[IllegalArgumentException](sql(s"SET mapred.reduce.tasks=-01"))
871+
intercept[IllegalArgumentException](sql(s"SET mapred.reduce.tasks=-2"))
869872
conf.clear()
870873
}
871874

0 commit comments

Comments
 (0)