Skip to content

Commit 1d282b8

Browse files
committed
Removes the Simba ODBC "SET -v" hack
1 parent f857fce commit 1d282b8

File tree

2 files changed

+32
-72
lines changed

2 files changed

+32
-72
lines changed

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

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -53,50 +53,35 @@ case class SetCommand(kv: Option[(String, Option[String])], output: Seq[Attribut
5353
extends LeafNode with Command with Logging {
5454

5555
override protected lazy val sideEffectResult: Seq[Row] = kv match {
56-
// Set value for the key.
57-
case Some((key, Some(value))) =>
58-
if (key == SQLConf.Deprecated.MAPRED_REDUCE_TASKS) {
59-
logWarning(s"Property ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS} is deprecated, " +
56+
// Configures the deprecated "mapred.reduce.tasks" property.
57+
case Some((SQLConf.Deprecated.MAPRED_REDUCE_TASKS, Some(value))) =>
58+
logWarning(
59+
s"Property ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS} is deprecated, " +
6060
s"automatically converted to ${SQLConf.SHUFFLE_PARTITIONS} instead.")
61-
context.setConf(SQLConf.SHUFFLE_PARTITIONS, value)
62-
Seq(Row(s"${SQLConf.SHUFFLE_PARTITIONS}=$value"))
63-
} else {
64-
context.setConf(key, value)
65-
Seq(Row(s"$key=$value"))
66-
}
67-
68-
// Query the value bound to the key.
61+
context.setConf(SQLConf.SHUFFLE_PARTITIONS, value)
62+
Seq(Row(s"${SQLConf.SHUFFLE_PARTITIONS}=$value"))
63+
64+
// Configures a single property.
65+
case Some((key, Some(value))) =>
66+
context.setConf(key, value)
67+
Seq(Row(s"$key=$value"))
68+
69+
// Queries all key-value pairs that are set in the SQLConf of the context. Notice that different
70+
// from Hive, here "SET -v" is an alias of "SET". (In Hive, "SET" returns all changed properties
71+
// while "SET -v" returns all properties.)
72+
case Some(("-v", None)) | None =>
73+
context.getAllConfs.map { case (k, v) => Row(s"$k=$v") }.toSeq
74+
75+
// Queries the deprecated "mapred.reduce.tasks" property.
76+
case Some((SQLConf.Deprecated.MAPRED_REDUCE_TASKS, None)) =>
77+
logWarning(
78+
s"Property ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS} is deprecated, " +
79+
s"showing ${SQLConf.SHUFFLE_PARTITIONS} instead.")
80+
Seq(Row(s"${SQLConf.SHUFFLE_PARTITIONS}=${context.numShufflePartitions}"))
81+
82+
// Queries a single property.
6983
case Some((key, None)) =>
70-
// TODO (lian) This is just a workaround to make the Simba ODBC driver work.
71-
// Should remove this once we get the ODBC driver updated.
72-
if (key == "-v") {
73-
val hiveJars = Seq(
74-
"hive-exec-0.12.0.jar",
75-
"hive-service-0.12.0.jar",
76-
"hive-common-0.12.0.jar",
77-
"hive-hwi-0.12.0.jar",
78-
"hive-0.12.0.jar").mkString(":")
79-
80-
context.getAllConfs.map { case (k, v) =>
81-
Row(s"$k=$v")
82-
}.toSeq ++ Seq(
83-
Row("system:java.class.path=" + hiveJars),
84-
Row("system:sun.java.command=shark.SharkServer2"))
85-
} else {
86-
if (key == SQLConf.Deprecated.MAPRED_REDUCE_TASKS) {
87-
logWarning(s"Property ${SQLConf.Deprecated.MAPRED_REDUCE_TASKS} is deprecated, " +
88-
s"showing ${SQLConf.SHUFFLE_PARTITIONS} instead.")
89-
Seq(Row(s"${SQLConf.SHUFFLE_PARTITIONS}=${context.numShufflePartitions}"))
90-
} else {
91-
Seq(Row(s"$key=${context.getConf(key, "<undefined>")}"))
92-
}
93-
}
94-
95-
// Query all key-value pairs that are set in the SQLConf of the context.
96-
case _ =>
97-
context.getAllConfs.map { case (k, v) =>
98-
Row(s"$k=$v")
99-
}.toSeq
84+
Seq(Row(s"$key=${context.getConf(key, "<undefined>")}"))
10085
}
10186

10287
override def otherCopyArgs = context :: Nil

sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveQuerySuite.scala

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ class HiveQuerySuite extends HiveComparisonTest {
769769
}.toSet
770770
clear()
771771

772-
// "set" itself returns all config variables currently specified in SQLConf.
772+
// "SET" itself returns all config variables currently specified in SQLConf.
773773
// TODO: Should we be listing the default here always? probably...
774774
assert(sql("SET").collect().size == 0)
775775

@@ -778,44 +778,19 @@ class HiveQuerySuite extends HiveComparisonTest {
778778
}
779779

780780
assert(hiveconf.get(testKey, "") == testVal)
781-
assertResult(Set(testKey -> testVal)) {
782-
collectResults(sql("SET"))
783-
}
781+
assertResult(Set(testKey -> testVal))(collectResults(sql("SET")))
782+
assertResult(Set(testKey -> testVal))(collectResults(sql("SET -v")))
784783

785784
sql(s"SET ${testKey + testKey}=${testVal + testVal}")
786785
assert(hiveconf.get(testKey + testKey, "") == testVal + testVal)
787786
assertResult(Set(testKey -> testVal, (testKey + testKey) -> (testVal + testVal))) {
788787
collectResults(sql("SET"))
789788
}
790-
791-
// "set key"
792-
assertResult(Set(testKey -> testVal)) {
793-
collectResults(sql(s"SET $testKey"))
794-
}
795-
796-
assertResult(Set(nonexistentKey -> "<undefined>")) {
797-
collectResults(sql(s"SET $nonexistentKey"))
798-
}
799-
800-
// Assert that sql() should have the same effects as sql() by repeating the above using sql().
801-
clear()
802-
assert(sql("SET").collect().size == 0)
803-
804-
assertResult(Set(testKey -> testVal)) {
805-
collectResults(sql(s"SET $testKey=$testVal"))
806-
}
807-
808-
assert(hiveconf.get(testKey, "") == testVal)
809-
assertResult(Set(testKey -> testVal)) {
810-
collectResults(sql("SET"))
811-
}
812-
813-
sql(s"SET ${testKey + testKey}=${testVal + testVal}")
814-
assert(hiveconf.get(testKey + testKey, "") == testVal + testVal)
815789
assertResult(Set(testKey -> testVal, (testKey + testKey) -> (testVal + testVal))) {
816-
collectResults(sql("SET"))
790+
collectResults(sql("SET -v"))
817791
}
818792

793+
// "SET key"
819794
assertResult(Set(testKey -> testVal)) {
820795
collectResults(sql(s"SET $testKey"))
821796
}

0 commit comments

Comments
 (0)