maropu commented on a change in pull request #28830:
URL: https://github.com/apache/spark/pull/28830#discussion_r439904040
##########
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 and it looks the same:
https://github.com/scala/scala/blob/2.12.x/src/library/scala/collection/SeqLike.scala#L504-L523
But, (I'm not a Scala compiler expert though), the `distinct` scala API makes
sure an input order is preserved? I read [the @HeartSaVioR comment
](https://issues.apache.org/jira/browse/SPARK-31990?focusedCommentId=17135286&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17135286)
in the Jira, then I'm not sure about that. So, I wrote this method to preserve
the order explicitly for safeguard.
----------------------------------------------------------------
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]