Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/10174#discussion_r47677958
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/DefaultOptimizerExtendableSuite.scala
 ---
    @@ -0,0 +1,45 @@
    +/*
    + * 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.catalyst
    +
    +import org.apache.spark.SparkFunSuite
    +import org.apache.spark.sql.catalyst.optimizer.{DefaultOptimizer, 
Optimizer}
    +import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
    +import org.apache.spark.sql.catalyst.rules.Batch
    +
    +/**
    +  * This is a test for SPARK-7727 if the Default Optimizer is kept being 
extendable
    +  */
    +class DefaultOptimizerExtendableSuite extends SparkFunSuite {
    --- End diff --
    
    If this is the goal, I think this change could be a lot smaller (and thus a 
lot less disruptive to people who are already extending catalyst).
    
    ```
    diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
    index f608869..f52dab1 100644
    --- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
    +++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
    @@ -28,10 +28,8 @@ import org.apache.spark.sql.catalyst.plans.logical._
     import org.apache.spark.sql.catalyst.rules._
     import org.apache.spark.sql.types._
     
    -abstract class Optimizer extends RuleExecutor[LogicalPlan]
    -
    -object DefaultOptimizer extends Optimizer {
    -  val batches =
    +abstract class Optimizer extends RuleExecutor[LogicalPlan] {
    +  def batches =
         // SubQueries are only needed for analysis and can be removed before 
execution.
         Batch("Remove SubQueries", FixedPoint(100),
           EliminateSubQueries) ::
    @@ -68,6 +66,11 @@ object DefaultOptimizer extends Optimizer {
           ConvertToLocalRelation) :: Nil
     }
     
    +object DefaultOptimizer extends Optimizer {
    +  val myBatches = Nil
    +  override def batches = super.batches ++ myBatches
    +}
    +
     /**
      * Pushes operations down into a Sample.
      */
    diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/rules/RuleExecutor.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/rules/RuleExecutor.scala
    index f80d2a9..62ea731 100644
    --- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/rules/RuleExecutor.scala
    +++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/rules/RuleExecutor.scala
    @@ -59,7 +59,7 @@ abstract class RuleExecutor[TreeType <: TreeNode[_]] 
extends Logging {
       protected case class Batch(name: String, strategy: Strategy, rules: 
Rule[TreeType]*)
     
       /** Defines a sequence of rule batches, to be overridden by the 
implementation. */
    -  protected val batches: Seq[Batch]
    +  protected def batches: Seq[Batch]
     
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to