jingz-db commented on code in PR #48005:
URL: https://github.com/apache/spark/pull/48005#discussion_r1828396968
##########
sql/core/src/main/scala/org/apache/spark/sql/RelationalGroupedDataset.scala:
##########
@@ -474,24 +474,61 @@ class RelationalGroupedDataset protected[sql](
func: Column,
outputStructType: StructType,
outputModeStr: String,
- timeModeStr: String): DataFrame = {
- val groupingNamedExpressions = groupingExprs.map {
- case ne: NamedExpression => ne
- case other => Alias(other, other.toString)()
+ timeModeStr: String,
+ initialState: RelationalGroupedDataset): DataFrame = {
+ def exprToAttr(expr: Seq[Expression]): Seq[Attribute] = {
+ expr.map {
+ case ne: NamedExpression => ne
+ case other => Alias(other, other.toString)()
+ }.map(_.toAttribute)
}
- val groupingAttrs = groupingNamedExpressions.map(_.toAttribute)
+
+ val groupingAttrs = exprToAttr(groupingExprs)
val outputAttrs = toAttributes(outputStructType)
val outputMode = InternalOutputModes(outputModeStr)
val timeMode = TimeModes(timeModeStr)
- val plan = TransformWithStateInPandas(
- func.expr,
- groupingAttrs,
- outputAttrs,
- outputMode,
- timeMode,
- child = df.logicalPlan
- )
+ val plan: LogicalPlan = if (initialState == null) {
+ TransformWithStateInPandas(
Review Comment:
You are correct about this; somehow I missed this previously. Thanks for
catching this! I add a projection and also a new test case for non-contiguous
with no initial state.
--
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]