Skip to content

Commit

Permalink
Support DecimalType for approx_count_distinct
Browse files Browse the repository at this point in the history
  • Loading branch information
liujiayi771 committed May 25, 2024
1 parent 9f424a1 commit f99168c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ case class HLLRewriteRule(spark: SparkSession) extends Rule[LogicalPlan] {
case LongType => true
case ShortType => true
case StringType => true
case _: DecimalType => true
case _ => false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,26 @@ abstract class VeloxAggregateFunctionsSuite extends VeloxWholeStageTransformerSu
}
}

test("approx_count_distinct decimal") {
// The data type of l_discount is decimal.
runQueryAndCompare("""
|select approx_count_distinct(l_discount) from lineitem;
|""".stripMargin) {
checkGlutenOperatorMatch[HashAggregateExecTransformer]
}
runQueryAndCompare(
"select approx_count_distinct(l_discount), count(distinct l_orderkey) from lineitem") {
df =>
{
assert(
getExecutedPlan(df).count(
plan => {
plan.isInstanceOf[HashAggregateExecTransformer]
}) == 0)
}
}
}

test("max_by") {
runQueryAndCompare(s"""
|select max_by(l_linenumber, l_comment) from lineitem;
Expand Down

0 comments on commit f99168c

Please sign in to comment.