File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
main/scala/org/apache/spark/sql
test/scala/org/apache/spark/sql Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff line change @@ -36,11 +36,6 @@ import org.apache.spark.sql.types._
3636class 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}
You can’t perform that action at this time.
0 commit comments