cloud-fan commented on code in PR #38276:
URL: https://github.com/apache/spark/pull/38276#discussion_r1000451568
##########
connector/connect/src/main/scala/org/apache/spark/sql/connect/planner/SparkConnectPlanner.scala:
##########
@@ -91,6 +93,40 @@ class SparkConnectPlanner(plan: proto.Relation, session:
SparkSession) {
transformRelation(rel.getInput))
}
+ private def transformDeduplicate(rel: proto.Deduplicate): LogicalPlan = {
+ if (!rel.hasInput) {
+ throw InvalidPlanInput("Deduplicate needs a plan input")
+ }
+ if (rel.getIsAll && rel.getColumnNamesCount > 0) {
+ throw InvalidPlanInput("Cannot deduplicate on both all columns and a
subset of columns")
+ }
+ if (!rel.getIsAll && rel.getColumnNamesCount == 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
+ if (rel.getIsAll) {
+ Deduplicate(allColumns, queryExecution.analyzed)
+ } else {
+ val toGroupColumnNames = rel.getColumnNamesList.asScala.toSeq
+ // TODO: Connect does not support streaming now. But once we do,
SPARK-31990 will need
+ // `toSet.toSeq` for `toGroupColumnNames` because of the backward
compatibility issue
+ // (the Streaming's state store depends on the `groupCols` order).
Review Comment:
I don't think spark connect will have backward compatibility issues. It's a
new API.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]