zzcclp commented on a change in pull request #31404: URL: https://github.com/apache/spark/pull/31404#discussion_r575769956
########## File path: sql/core/src/test/scala/org/apache/spark/sql/DataFrameSetOperationsSuite.scala ########## @@ -385,6 +385,90 @@ class DataFrameSetOperationsSuite extends QueryTest with SharedSparkSession { checkAnswer(unionDF, unionAllDF) } + test("SQL-style union using Dataset: remove unnecessary deduplicate in multiple unions") { + val unionDF = testData.union(testData).distinct().union(testData).distinct() + .union(testData).distinct().union(testData).distinct() + + // Before optimizer, there are three 'union.deduplicate' operations should be combined. + assert(unionDF.queryExecution.analyzed.collect { + case j: Union if j.children.size == 4 => j Review comment: IMO, it's more intuitional to count the number of Union, and the test cases related to Union above use this way to check. ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org