diff options
author | Davies Liu <davies@databricks.com> | 2015-08-19 13:56:40 -0700 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2015-08-19 13:56:40 -0700 |
commit | 08887369c890e0dd87eb8b34e8c32bb03307bf24 (patch) | |
tree | bd5b86d521b1da6809fa1266bf3e0eb6f1bef366 /python/pyspark/sql/tests.py | |
parent | e05da5cb5ea253e6372f648fc8203204f2a8df8d (diff) | |
download | spark-08887369c890e0dd87eb8b34e8c32bb03307bf24.tar.gz spark-08887369c890e0dd87eb8b34e8c32bb03307bf24.tar.bz2 spark-08887369c890e0dd87eb8b34e8c32bb03307bf24.zip |
[SPARK-10073] [SQL] Python withColumn should replace the old column
DataFrame.withColumn in Python should be consistent with the Scala one (replacing the existing column that has the same name).
cc marmbrus
Author: Davies Liu <davies@databricks.com>
Closes #8300 from davies/with_column.
Diffstat (limited to 'python/pyspark/sql/tests.py')
-rw-r--r-- | python/pyspark/sql/tests.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/python/pyspark/sql/tests.py b/python/pyspark/sql/tests.py index 13cf647b66..aacfb34c77 100644 --- a/python/pyspark/sql/tests.py +++ b/python/pyspark/sql/tests.py @@ -1035,6 +1035,10 @@ class SQLTests(ReusedPySparkTestCase): self.assertRaisesRegexp(IllegalArgumentException, "1024 is not in the permitted values", lambda: df.select(sha2(df.a, 1024)).collect()) + def test_with_column_with_existing_name(self): + keys = self.df.withColumn("key", self.df.key).select("key").collect() + self.assertEqual([r.key for r in keys], list(range(100))) + class HiveContextSQLTests(ReusedPySparkTestCase): |