You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/06/15 03:00:43 UTC

[GitHub] [spark] maropu commented on a change in pull request #28830: [SPARK-31990][SS] Preserves the input order of colNames in dropDuplicates

maropu commented on a change in pull request #28830:
URL: https://github.com/apache/spark/pull/28830#discussion_r439907906



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
##########
@@ -2541,7 +2542,20 @@ class Dataset[T] private[sql](
   def dropDuplicates(colNames: Seq[String]): Dataset[T] = withTypedPlan {
     val resolver = sparkSession.sessionState.analyzer.resolver
     val allColumns = queryExecution.analyzed.output
-    val groupCols = colNames.distinct.flatMap { (colName: String) =>
+    // SPARK-31990: We must preserve the input order of `colNames` because of the compatibility
+    // issue (the Streaming's state store depends on the `groupCols` order).
+    val orderPreservingDistinctColNames = {
+      val nameSeen = mutable.Set[String]()

Review comment:
       Ah, I see. Yea, I'll update the code based on `toSeq.toSeq`.

##########
File path: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala
##########
@@ -2541,7 +2542,20 @@ class Dataset[T] private[sql](
   def dropDuplicates(colNames: Seq[String]): Dataset[T] = withTypedPlan {
     val resolver = sparkSession.sessionState.analyzer.resolver
     val allColumns = queryExecution.analyzed.output
-    val groupCols = colNames.distinct.flatMap { (colName: String) =>
+    // SPARK-31990: We must preserve the input order of `colNames` because of the compatibility
+    // issue (the Streaming's state store depends on the `groupCols` order).
+    val orderPreservingDistinctColNames = {
+      val nameSeen = mutable.Set[String]()

Review comment:
       Ah, I see. Yea, I'll update the code based on `toSet.toSeq`.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org