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

    https://github.com/apache/spark/pull/8300#discussion_r37415899
  
    --- Diff: python/pyspark/sql/dataframe.py ---
    @@ -1223,10 +1226,8 @@ def withColumnRenamed(self, existing, new):
             >>> df.withColumnRenamed('age', 'age2').collect()
             [Row(age2=2, name=u'Alice'), Row(age2=5, name=u'Bob')]
             """
    -        cols = [Column(_to_java_column(c)).alias(new)
    -                if c == existing else c
    -                for c in self.columns]
    -        return self.select(*cols)
    +        assert existing in self.columns, "%s is not an existing column" % 
existing
    --- End diff --
    
    This is not consistent with scala version, see the 
[doc](https://github.com/apache/spark/blob/master/sql/core/src/main/scala/org/apache/spark/sql/DataFrame.scala#L1173),
 we should not report error here.
    
    Actually I'm wondering why we need to do checking at python side(not only 
this one)? Can we just call the scala API and catch the java exception?


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to