Skip to content

Commit fb59a8a

Browse files
committed
fixing code review comments
1 parent ff187c3 commit fb59a8a

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,9 +1256,12 @@ class DataFrame private[sql](
12561256
@scala.annotation.varargs
12571257
def drop(colNames: String*): DataFrame = {
12581258
val resolver = sqlContext.analyzer.resolver
1259+
12591260
val remainingCols =
12601261
schema.filter(f => colNames.forall(n => !resolver(f.name, n)))
1261-
.map(f => Column(UnresolvedAttribute(Seq(f.name))))
1262+
.map(f => Column(UnresolvedAttribute.quoted(f.name)))
1263+
1264+
12621265
if (remainingCols.size == this.schema.size) {
12631266
this
12641267
} else {

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ import org.apache.spark.sql.types._
3636
class DataFrameSuite extends QueryTest with SharedSQLContext {
3737
import testImplicits._
3838

39-
test("SPARK-12987") {
40-
val df = Seq((1, 1)).toDF("a_b", "a.c")
41-
val df1 = df.drop("a_b")
42-
assert(df1.toString() === "[a.c: int]")
43-
}
4439

4540
test("analysis error should be eagerly reported") {
4641
// Eager analysis.
@@ -1297,4 +1292,11 @@ class DataFrameSuite extends QueryTest with SharedSQLContext {
12971292
Seq(1 -> "a").toDF("i", "j").filter($"i".cast(StringType) === "1"),
12981293
Row(1, "a"))
12991294
}
1295+
1296+
test("SPARK-12987: drop column ") {
1297+
val df = Seq((1, 2)).toDF("a_b", "a.c")
1298+
val df1 = df.drop("a_b")
1299+
checkAnswer(df1, Row(2))
1300+
assert(df1.schema.map(_.name) === Seq("a.c"))
1301+
}
13001302
}

0 commit comments

Comments
 (0)