Skip to content

Commit

Permalink
[VL] Support DecimalType for approx_count_distinct (apache#5868)
Browse files Browse the repository at this point in the history
[VL] Support DecimalType for approx_count_distinct.
  • Loading branch information
liujiayi771 authored May 27, 2024
1 parent 95096e3 commit efd6f31
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 efd6f31

Please sign in to comment.