Ngone51 commented on a change in pull request #29270:
URL: https://github.com/apache/spark/pull/29270#discussion_r464305243



##########
File path: sql/core/src/test/scala/org/apache/spark/sql/PlanStabilitySuite.scala
##########
@@ -0,0 +1,300 @@
+/*
+ * 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.io.File
+import java.nio.charset.StandardCharsets
+
+import scala.collection.mutable
+
+import org.apache.commons.io.FileUtils
+
+import org.apache.spark.sql.catalyst.expressions.AttributeSet
+import org.apache.spark.sql.catalyst.util._
+import org.apache.spark.sql.execution._
+import org.apache.spark.sql.execution.adaptive.DisableAdaptiveExecutionSuite
+import org.apache.spark.sql.execution.exchange.{Exchange, ReusedExchangeExec}
+import org.apache.spark.sql.internal.SQLConf
+
+/**
+ * Check that TPCDS SparkPlans don't change.
+ * If there are plan differences, the error message looks like this:
+ *   Plans did not match:
+ *   last approved plan: 
/path/to/tpcds-plan-stability/approved-plans-xxx/q1/0.simplified.txt
+ *   last explain: 
/path/to/tpcds-plan-stability/approved-plans-xxx/q1/0.explain.txt
+ *   actual plan: /path/to/tmp/q1.actual.simplified.txt
+ *   actual explain: /path/to/tmp/q1.actual.explain.txt
+ *   [side by side plan diff]
+ * The explain files are saved to help debug later, they are not checked. Only 
the simplified
+ * plans are checked (by string comparison).
+ *
+ * Approving new plans:
+ * IF the plan change is intended then re-running the test
+ * with environ var SPARK_GENERATE_GOLDEN_FILES=1 will make the new plan canon.
+ * This should be done only for the queries that need it, to avoid unnecessary 
diffs in the
+ * other approved plans.
+ * This can be done by running sbt test-only *PlanStabilitySuite* -- -z "(q31)"
+ * The new plan files should be part of the PR and reviewed.
+ *
+ * Multiple approved plans:
+ * It's possible that a query has multiple correct plans. This should be 
decided as part of the
+ * review. In this case, change the call to approvePlans and set variant=true.

Review comment:
       I was trying to be consistent with Spark's original assumption that a 
query may have multiple physical plans and Spark needs to select the best one 
bases on some rules, e.g. cost-based rules. But it seems this gets unnecessary 
complexity since Spark doesn't really support that yet.
   
   And now, @cloud-fan @maropu have another idea which is to use `variant` to 
improve test coverage for the plan. e.g., we could test SMJ as well as BHJ for 
a certain plan basing on different table stats.




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

Reply via email to