Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9862#discussion_r46646105
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala ---
    @@ -1241,16 +1241,22 @@ class DataFrame private[sql](
        * @since 1.4.0
        */
       def drop(colName: String): DataFrame = {
    -    val resolver = sqlContext.analyzer.resolver
    -    val shouldDrop = schema.exists(f => resolver(f.name, colName))
    -    if (shouldDrop) {
    -      val colsAfterDrop = schema.filter { field =>
    -        val name = field.name
    -        !resolver(name, colName)
    -      }.map(f => Column(f.name))
    -      select(colsAfterDrop : _*)
    -    } else {
    +    drop(Seq(colName) : _*)
    +  }
    +
    +  /**
    +   * Returns a new [[DataFrame]] with columns dropped.
    +   * This is a no-op if schema doesn't contain column name(s).
    +   * @group dfops
    +   * @since 1.6.0
    +   */
    +  @scala.annotation.varargs
    +  def drop(colNames: String*): DataFrame = {
    +    val remainingCols = this.schema.filter(f => 
colNames.contains(f.name)).map(f => Column(f.name))
    --- End diff --
    
    why using `contains` instead of using `sqlContext.analyzer.resolver`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to