viirya commented on a change in pull request #32431:
URL: https://github.com/apache/spark/pull/32431#discussion_r627873450
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
##########
@@ -2395,6 +2395,36 @@ class Dataset[T] private[sql](
*/
def withColumn(colName: String, col: Column): DataFrame =
withColumns(Seq(colName), Seq(col))
+ /**
+ * (Scala-specific) Returns a new Dataset by adding columns or replacing the
existing columns
+ * that has the same names.
+ *
+ * `colsMap` is a map of column name and column, the column must only refer
to attributes
+ * supplied by this Dataset. It is an error to add columns that refers to
some other Dataset.
+ *
+ * @group untypedrel
+ * @since 3.2.0
+ */
+ def withColumns(colsMap: Map[String, Column]): DataFrame = {
+ val colNames = colsMap.flatMap{ case (colName, _) => Seq(colName) }.toSeq
Review comment:
oh, we should better do `val (colNames, newCols) = colsMap.toSeq.unzip`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]