Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/737#discussion_r12546769
--- 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 --
Having a default here is reasonable, but we should probably expose this to
the user as well. Maybe two versions in the parser?
---
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.
---