Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/10067#discussion_r46353257
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -223,10 +223,13 @@ class Analyzer(
case other => Alias(other, other.toString)()
}
- // TODO: We need to use bitmasks to determine which grouping
expressions need to be
- // set as nullable. For example, if we have GROUPING SETS ((a,b),
a), we do not need
- // to change the nullability of a.
- val attributeMap = groupByAliases.map(a => (a ->
a.toAttribute.withNullability(true))).toMap
+ val attributeMap = groupByAliases.zipWithIndex.map { case (a, idx)
=>
+ if (x.bitmasks.exists(bitmask => (bitmask & 1 << idx) == 0)) {
+ (a -> a.toAttribute.withNullability(true))
+ } else {
+ (a -> a.toAttribute)
+ }
+ }.toMap
--- End diff --
It is the same thing. I only suggested to aggregate the bitmap in advance:
```val nonNullBitmask = x.bitmasks.reduce(_ & _)``` and to use the
```nonNullBitmask``` to check for (non) nullability in the loop. It should be a
tiny tiny tiny bit quicker (no re-iteration required , and less one closure).
---
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.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]