Github user sun-rui commented on a diff in the pull request: https://github.com/apache/spark/pull/10201#discussion_r47042545 --- Diff: R/pkg/R/DataFrame.R --- @@ -1324,12 +1312,16 @@ setMethod("selectExpr", #' path <- "path/to/file.json" #' df <- jsonFile(sqlContext, path) #' newDF <- withColumn(df, "newCol", df$col1 * 5) +#' # Replace an existing column +#' newDF2 <- withColumn(newDF, "newCol", newDF$col1) --- End diff -- I don't know the reason. The original commit can be found at https://github.com/amplab-extras/SparkR-pkg/pull/204. I don't think it is related to supporting multiple columns with the same name. Spark Core itself allows multiple columns with the same name: ``` scala> val df=sqlContext.createDataFrame(Seq((1,2,3))).toDF("a","a","c") df: org.apache.spark.sql.DataFrame = [a: int, a: int, c: int] scala> df.show +---+---+---+ | a| a| c| +---+---+---+ | 1| 2| 3| +---+---+---+ scala> df.withColumn("a", df("c")).show +---+---+---+ | a| a| c| +---+---+---+ | 3| 3| 3| +---+---+---+ ``` You can see all columns of the same name will be replaced in the above example.
--- 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