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 2022/10/17 14:57:35 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #38276: [SPARK-40812][CONNECT] Add Deduplicate to Connect proto and DSL

cloud-fan commented on code in PR #38276:
URL: https://github.com/apache/spark/pull/38276#discussion_r997170213


##########
connector/connect/src/main/scala/org/apache/spark/sql/connect/planner/SparkConnectPlanner.scala:
##########
@@ -71,6 +73,42 @@ class SparkConnectPlanner(plan: proto.Relation, session: SparkSession) {
     session.sessionState.sqlParser.parsePlan(sql.getQuery)
   }
 
+  private def transformDeduplicate(rel: proto.Deduplicate): LogicalPlan = {
+    if (!rel.hasInput) {
+      throw InvalidPlanInput("Deduplicate needs a plan input")
+    }
+    if (rel.getIsAll && rel.getDeduplicateColumnsCount > 0) {
+      throw InvalidPlanInput("Cannot deduplicate on both all columns and a subset of columns")
+    }
+    if (!rel.getIsAll && rel.getDeduplicateColumnsCount == 0) {
+      throw InvalidPlanInput(
+        "Deduplicate requires to either deduplicate on all columns or a subset of columns")
+    }
+    val queryExecution = new QueryExecution(session, transformRelation(rel.getInput))
+    val resolver = session.sessionState.analyzer.resolver
+    val allColumns = queryExecution.analyzed.output
+    val toGroupColumnNames = {
+      if (rel.getIsAll) {
+        allColumns.map(t => t.name).toSeq

Review Comment:
   We don't need to do name lookup. We can just create `Deduplicate(allColumns, queryExecution.analyzed)`



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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