zhengruifeng opened a new pull request, #44454:
URL: https://github.com/apache/spark/pull/44454
### What changes were proposed in this pull request?
Retain `plan_id` in `ResolveUnpivot` and `UnpivotCoercion`
### Why are the changes needed?
they drop the plan id add cause:
```
In [1]: df = spark.createDataFrame([(1, 2, 3, 4, 5, 6)], ["f1", "f2",
"label", "pred", "model_version", "ts"])
...: df.melt("model_version", ["label", "f2"], "f1",
"f2").groupby("f1").count().count()
23/12/22 11:37:52 WARN CheckAllocator: More than one
DefaultAllocationManager on classpath. Choosing first found
---------------------------------------------------------------------------
AnalysisException Traceback (most recent call last)
...
AnalysisException: When resolving 'f1, fail to find subplan with plan_id=2
in 'Aggregate ['f1], ['f1, count(1) AS count#125L]
+- Expand [[model_version#117L, label, label#115L], [model_version#117L, f2,
f2#114L]], [model_version#117L, f1#126, f2#127L]
+- Project [f1#101L AS f1#113L, f2#102L AS f2#114L, label#103L AS
label#115L, pred#104L AS pred#116L, model_version#105L AS model_version#117L,
ts#106L AS ts#118L]
+- LocalRelation [f1#101L, f2#102L, label#103L, pred#104L,
model_version#105L, ts#106L]
JVM stacktrace:
org.apache.spark.sql.AnalysisException
at
org.apache.spark.sql.catalyst.analysis.ColumnResolutionHelper.$anonfun$resolveUnresolvedAttributeByPlanId$3(ColumnResolutionHelper.scala:521)
at scala.Option.getOrElse(Option.scala:201)
at
org.apache.spark.sql.catalyst.analysis.ColumnResolutionHelper.$anonfun$resolveUnresolvedAttributeByPlanId$2(ColumnResolutionHelper.scala:516)
at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:469)
at
org.apache.spark.sql.catalyst.analysis.ColumnResolutionHelper.resolveUnresolvedAttributeByPlanId(ColumnResolutionHelper.scala:511)
at
org.apache.spark.sql.catalyst.analysis.ColumnResolutionHelper.tryResolveColumnByPlanId(ColumnResolutionHelper.scala:494)
```
### Does this PR introduce _any_ user-facing change?
yes, bug fix
### How was this patch tested?
added ut
### Was this patch authored or co-authored using generative AI tooling?
no
--
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]