grundprinzip commented on code in PR #38276:
URL: https://github.com/apache/spark/pull/38276#discussion_r997381115
##########
connector/connect/src/main/protobuf/spark/connect/relations.proto:
##########
@@ -163,6 +164,14 @@ message Sort {
}
}
+// Relation of type [[Deduplicate]] which have duplicate rows removed, could
consider either only
+// the subset of columns or all the columns.
+message Deduplicate {
+ Relation input = 1;
+ repeated string deduplicate_columns = 2;
+ bool is_all = 3;
Review Comment:
So the question is if `is_all` is a nice convenience hack or strictly
necessary, I'm ok with both :)
##########
connector/connect/src/test/scala/org/apache/spark/sql/connect/planner/SparkConnectDeduplicateSuite.scala:
##########
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.sql.connect.planner
+
+import org.apache.spark.sql.{Dataset, Row, SparkSession}
+import org.apache.spark.sql.catalyst.expressions.AttributeReference
+import org.apache.spark.sql.test.SharedSparkSession
+import org.apache.spark.sql.types.{IntegerType, StringType, StructField,
StructType}
+
+/**
+ * [[SparkConnectPlanTestWithSparkSession]] contains a SparkSession for the
connect planner.
+ *
+ * It is not recommended to use Catalyst DSL along with this trait because
`SharedSparkSession`
+ * has also defined implicits over Catalyst LogicalPlan which will cause
ambiguity with the
+ * implicits defined in Catalyst DSL.
+ */
+trait SparkConnectPlanTestWithSparkSession extends SharedSparkSession with
SparkConnectPlanTest {
+ override def getSession(): SparkSession = spark
+}
+
+class SparkConnectDeduplicateSuite extends
SparkConnectPlanTestWithSparkSession {
+ lazy val connectTestRelation = createLocalRelationProto(
+ Seq(AttributeReference("id", IntegerType)(),
+ AttributeReference("key", StringType)(),
+ AttributeReference("value", StringType)()))
+
+ lazy val sparkTestRelation = {
+ spark.createDataFrame(
+ java.util.List.of[Row](),
+ StructType(Seq(
+ StructField("id", IntegerType),
+ StructField("key", StringType),
+ StructField("value", StringType)
+ )))
+ }
+
+
+ test("Test basic deduplicate") {
+ val connectPlan = {
+ import org.apache.spark.sql.connect.dsl.plans._
+ Dataset.ofRows(spark, transform(connectTestRelation.distinct()))
+ }
+
+ val sparkPlan = sparkTestRelation.distinct()
+ comparePlans(connectPlan.queryExecution.analyzed,
sparkPlan.queryExecution.analyzed, false)
+
+ val connectPlan2 = {
+ import org.apache.spark.sql.connect.dsl.plans._
+ Dataset.ofRows(spark,
transform(connectTestRelation.deduplicate(Seq("key", "value"))))
+ }
Review Comment:
I think there was an issue here with the way that the two implicits of Spark
and Spark Connect DSL are handled.
##########
connector/connect/src/main/protobuf/spark/connect/relations.proto:
##########
@@ -163,6 +164,14 @@ message Sort {
}
}
+// Relation of type [[Deduplicate]] which have duplicate rows removed, could
consider either only
+// the subset of columns or all the columns.
+message Deduplicate {
+ Relation input = 1;
+ repeated string deduplicate_columns = 2;
+ bool is_all = 3;
Review Comment:
given the usage of `is_all` can't this be inferred by the list of columns?
If they're identical is_all is true?
--
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]