Github user larvaboy commented on a diff in the pull request:
https://github.com/apache/spark/pull/737#discussion_r12574394
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregates.scala
---
@@ -166,10 +167,48 @@ case class CountDistinct(expressions:
Seq[Expression]) extends AggregateExpressi
override def references = expressions.flatMap(_.references).toSet
override def nullable = false
override def dataType = IntegerType
- override def toString = s"COUNT(DISTINCT ${expressions.mkString(",")}})"
+ override def toString = s"COUNT(DISTINCT ${expressions.mkString(",")})"
override def newInstance() = new CountDistinctFunction(expressions, this)
}
+case class ApproxCountDistinctPartition(child: Expression)
+ extends AggregateExpression with trees.UnaryNode[Expression] {
+ override def references = child.references
+ override def nullable = false
+ override def dataType = child.dataType
+ override def toString = s"APPROXIMATE COUNT(DISTINCT $child)"
+ override def newInstance() = new
ApproxCountDistinctPartitionFunction(child, this)
+}
+
+case class ApproxCountDistinctMerge(child: Expression)
+ extends AggregateExpression with trees.UnaryNode[Expression] {
+ override def references = child.references
+ override def nullable = false
+ override def dataType = IntegerType
+ override def toString = s"APPROXIMATE COUNT(DISTINCT $child)"
+ override def newInstance() = new ApproxCountDistinctMergeFunction(child,
this)
+}
+
+object ApproxCountDistinct {
+ val RelativeSD = 0.05
--- End diff --
Please refer to the most recent version where we have another parser
allowing users to pass in the standard deviation.
The first version has the benefit of hiding the implementation details from
the user. The standard deviation is not an intuitive parameter for an end user,
especially given its side effect to the memory usage.
Please let me know your thoughts on the new version.
---
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.
---