cloud-fan commented on a change in pull request #33286:
URL: https://github.com/apache/spark/pull/33286#discussion_r670962182
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/EstimationUtils.scala
##########
@@ -52,14 +52,18 @@ object EstimationUtils {
}
/**
- * Updates (scales down) the number of distinct values if the number of rows
decreases after
- * some operation (such as filter, join). Otherwise keep it unchanged.
+ * Updates (scales down) a statistic (eg. number of distinct values) if the
number of rows
+ * decreases after some operation (such as filter, join). Otherwise keep it
unchanged.
*/
- def updateNdv(oldNumRows: BigInt, newNumRows: BigInt, oldNdv: BigInt):
BigInt = {
- if (newNumRows < oldNumRows) {
- ceil(BigDecimal(oldNdv) * BigDecimal(newNumRows) /
BigDecimal(oldNumRows))
+ def updateStat(
+ oldNumRows: BigInt,
+ newNumRows: BigInt,
+ oldStat: BigInt,
+ updatedStat: BigInt): BigInt = {
+ if (updatedStat > 1 && newNumRows < oldNumRows) {
Review comment:
can we keep the old comment? `// no need to scale down since it is
already down to 1`
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]