You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "HyukjinKwon (via GitHub)" <gi...@apache.org> on 2023/02/08 00:40:13 UTC

[GitHub] [spark] HyukjinKwon commented on a diff in pull request #39933: [SPARK-42377][Connect] Test framework for Spark Connect Scala Client

HyukjinKwon commented on code in PR #39933:
URL: https://github.com/apache/spark/pull/39933#discussion_r1099483089


##########
connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/PlanGenerationTestSuite.scala:
##########
@@ -0,0 +1,247 @@
+/*
+ * 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
+
+import java.nio.file.{Files, Path}
+
+import scala.collection.mutable
+import scala.util.{Failure, Success, Try}
+
+import com.google.protobuf.util.JsonFormat
+import io.grpc.inprocess.InProcessChannelBuilder
+import org.scalatest.BeforeAndAfterAll
+import org.scalatest.funsuite.{AnyFunSuite => ConnectFunSuite} // scalastyle:ignore funsuite
+
+import org.apache.spark.connect.proto
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.{functions => fn}
+import org.apache.spark.sql.connect.client.SparkConnectClient
+import org.apache.spark.sql.types.StructType
+
+// scalastyle:off
+/**
+ * Test the plans generated by the client. This serves two purposes:
+ * 1. Make sure the generated plan matches our expectations.
+ *    The generated JSON file can be used for this during review.
+ * 2. Make sure the generated plans are stable. Changes to the generated plans should be rare. The
+ *    generated plan is compared to the (previously) generated proto file; the test fails when
+ *    they are different.
+ *
+ * If you need to re-generate the golden files, you need to set the SPARK_GENERATE_GOLDEN_FILES=1
+ * environment variable before running this test, e.g.:
+ * {{{
+ *   SPARK_GENERATE_GOLDEN_FILES=1 build/sbt "connect-client-jvm/testOnly org.apache.spark.sql.PlanGenerationTestSuite"
+ * }}}
+ *
+ * Note that the plan protos are used as the input for the `ProtoToParsedPlanTestSuite` in the
+ * `connector/connect/server` module
+ */
+// scalastyle:on
+class PlanGenerationTestSuite extends ConnectFunSuite with BeforeAndAfterAll with Logging {

Review Comment:
   Can be done in a followup but I believe we can reuse some codes in `PlanStabilitySuite` cc @cloud-fan and @Ngone51 FYI



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