comphead commented on code in PR #7566:
URL: https://github.com/apache/datafusion-comet/pull/7566#discussion_r4743954516
##########
spark/src/main/scala/org/apache/spark/sql/comet/operators.scala:
##########
@@ -2580,6 +2572,29 @@ trait CometBaseAggregate[T <: BaseAggregateExec] extends
CometOperatorSerde[T] {
}
+object CometBaseAggregate {
+
+ /**
+ * The reason Comet cannot group on `groupingExpressions` because of their
data types, or `None`
+ * if their types are supported. Both `CometBaseAggregate.doConvert` and
+ * `CometExecRule.canAggregateBeConverted` call this, so the grouping key
checks cannot drift
+ * between the two.
+ */
+ def unsupportedGroupingReason(groupingExpressions: Seq[Expression]):
Option[String] = {
+ if (groupingExpressions.exists(expr =>
+ SupportLevel.containsType(expr.dataType, classOf[MapType]))) {
+ Some("Grouping on map-containing types is not supported")
+ } else if (groupingExpressions.exists(expr =>
isStringCollationType(expr.dataType))) {
Review Comment:
This only looks at the top-level type of each grouping key. Spark plans a
sort aggregate for a key that merely contains a collated string, such as
`STRUCT<s: STRING COLLATE UTF8_LCASE>` or an array of one, because
`Aggregate.supportsHashAggregate` uses `UnsafeRowUtils.isBinaryStable`, which
recurses (`v4.1.1`, `basicLogicalOperators.scala` line 1212 and
`UnsafeRowUtils.scala` line 207). The sort guard already uses the nested-aware
`hasNonDefaultStringCollation` (`QueryPlanSerde.supportedSortType`), and it is
already imported in this file. Now that both callers go through this helper,
would switching to `hasNonDefaultStringCollation(expr.dataType)` here close the
same latent gap for nested keys in one place? I did not run this, and I did not
check whether a nested key can reach the aggregate with a native child today.
--
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]