Github user davies commented on a diff in the pull request: https://github.com/apache/spark/pull/8300#discussion_r37439516 --- 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 -- Good catch, will remove it. I'm really surprised by the behavior in Scala. The reason we want to have some check on Python side is that the Java exception is not easy to understand for Python programmer (nested inside a Py4j exception). The Python exception or messages does improve the experience for Python programmer, especially beginners.
--- 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