Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/11583#discussion_r57541319
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
---
@@ -309,38 +309,64 @@ class Analyzer(
object ResolvePivot extends Rule[LogicalPlan] {
def apply(plan: LogicalPlan): LogicalPlan = plan transform {
- case p: Pivot if !p.childrenResolved |
!p.aggregates.forall(_.resolved) => p
+ case p: Pivot if !p.childrenResolved |
!p.aggregates.forall(_.resolved)
+ | !p.groupByExprs.forall(_.resolved) | !p.pivotColumn.resolved => p
case Pivot(groupByExprs, pivotColumn, pivotValues, aggregates,
child) =>
val singleAgg = aggregates.size == 1
- val pivotAggregates: Seq[NamedExpression] = pivotValues.flatMap {
value =>
- def ifExpr(expr: Expression) = {
- If(EqualTo(pivotColumn, value), expr, Literal(null))
+ def outputName(value: Literal, aggregate: Expression): String = {
+ if (singleAgg) value.toString else value + "_" + aggregate.sql
+ }
+ if (pivotValues.length >= 10
+ && aggregates.forall(a =>
PivotFirst.supportsDataType(a.dataType))) {
--- End diff --
Will it better if we remove `pivotValues.length` and just keep
`aggregates.forall(a => PivotFirst.supportsDataType(a.dataType))`? Also, which
data types does the new code path not support?
---
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]