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

    https://github.com/apache/spark/pull/16228#discussion_r92526006
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/estimation/JoinEstimation.scala
 ---
    @@ -0,0 +1,175 @@
    +/*
    + * 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.estimation
    +
    +import scala.collection.mutable
    +
    +import org.apache.spark.sql.catalyst.expressions.{AttributeReference, 
Expression}
    +import org.apache.spark.sql.catalyst.planning.ExtractEquiJoinKeys
    +import org.apache.spark.sql.catalyst.plans.logical.{ColumnStat, Join, 
Statistics}
    +import org.apache.spark.sql.types.DataType
    +
    +
    +object JoinEstimation {
    +  import EstimationUtils._
    +
    +  // scalastyle:off
    +  /**
    +   * Estimate output size and number of rows after a join operator, and 
propogate updated column
    +   * statsitics.
    +   * The number of rows of A inner join B on A.k1 = B.k1 is estimated by 
this basic formula:
    +   * T(A IJ B) = T(A) * T(B) / max(V(A.k1), V(B.k1)), where V is the 
number of distinct values of
    +   * that column. The underlying assumption for this formula is: each 
value of the smaller domain
    +   * is included in the larger domain.
    +   * Generally, inner join with multiple join keys can also be estimated 
based on the above
    +   * formula:
    +   * T(A IJ B) = T(A) * T(B) / (max(V(A.k1), V(B.k1)) * max(V(A.k2), 
V(B.k2)) * ... * max(V(A.kn), V(B.kn)))
    +   * However, the denominator can become very large and excessively reduce 
the result, so we use a
    +   * conservative strategy to take only the largest max(V(A.ki), V(B.ki)) 
as the denominator.
    +   *
    --- End diff --
    
    Yes, of course


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