Github user wzhfy commented on a diff in the pull request:
https://github.com/apache/spark/pull/17918#discussion_r115664061
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/JoinEstimation.scala
---
@@ -217,32 +217,18 @@ case class InnerOuterEstimation(conf: SQLConf, join:
Join) extends Logging {
if (joinKeyStats.contains(a)) {
outputAttrStats += a -> joinKeyStats(a)
} else {
- val leftRatio = if (leftRows != 0) {
- BigDecimal(outputRows) / BigDecimal(leftRows)
- } else {
- BigDecimal(0)
- }
- val rightRatio = if (rightRows != 0) {
- BigDecimal(outputRows) / BigDecimal(rightRows)
- } else {
- BigDecimal(0)
- }
val oldColStat = oldAttrStats(a)
val oldNdv = oldColStat.distinctCount
- // We only change (scale down) the number of distinct values if
the number of rows
- // decreases after join, because join won't produce new values
even if the number of
- // rows increases.
- val newNdv = if (join.left.outputSet.contains(a) && leftRatio < 1)
{
- ceil(BigDecimal(oldNdv) * leftRatio)
- } else if (join.right.outputSet.contains(a) && rightRatio < 1) {
- ceil(BigDecimal(oldNdv) * rightRatio)
+ val newNdv = if (join.left.outputSet.contains(a)) {
+ updateNdv(oldNumRows = leftRows, newNumRows = outputRows, oldNdv
= oldNdv)
} else {
- oldNdv
+ updateNdv(oldNumRows = rightRows, newNumRows = outputRows,
oldNdv = oldNdv)
}
+ val newColStat =
--- End diff --
Yes, please look at [this
line](https://github.com/apache/spark/pull/17918/files#diff-e068b2e4d8b82a9587450cd17d8d7226R791).
I don't know why it is not folded.
---
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]