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

    https://github.com/apache/spark/pull/16395#discussion_r100940942
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/FilterEstimation.scala
 ---
    @@ -0,0 +1,623 @@
    +/*
    + * 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.plans.logical.statsEstimation
    +
    +import java.sql.{Date, Timestamp}
    +
    +import scala.collection.immutable.{HashSet, Map}
    +import scala.collection.mutable
    +
    +import org.apache.spark.internal.Logging
    +import org.apache.spark.sql.catalyst.CatalystConf
    +import org.apache.spark.sql.catalyst.expressions._
    +import org.apache.spark.sql.catalyst.plans.logical._
    +import org.apache.spark.sql.catalyst.util.DateTimeUtils
    +import org.apache.spark.sql.types._
    +import org.apache.spark.unsafe.types.UTF8String
    +
    +/**
    + * @param plan a LogicalPlan node that must be an instance of Filter
    + * @param catalystConf a configuration showing if CBO is enabled
    + */
    +case class FilterEstimation(plan: Filter, catalystConf: CatalystConf) 
extends Logging {
    +
    +  /**
    +   * We use a mutable colStats because we need to update the corresponding 
ColumnStat
    +   * for a column after we apply a predicate condition.  For example, 
column c has
    +   * [min, max] value as [0, 100].  In a range condition such as (c > 40 
AND c <= 50),
    +   * we need to set the column's [min, max] value to [40, 100] after we 
evaluate the
    +   * first condition c > 40.  We need to set the column's [min, max] value 
to [40, 50]
    +   * after we evaluate the second condition c <= 50.
    +   */
    +  private var mutableColStats: mutable.Map[ExprId, ColumnStat] = 
mutable.Map.empty
    --- End diff --
    
    mutableColStats is a class member variable.  When we instantiate a Filter 
object, we need to set mutableColStats to mutable.Map.empty.  Afterwards, we 
need to re-assign it to a new value in method estimate.  Since we change the 
value of  mutableColStats, we need to declare it as a var variable.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to