vinodkc commented on code in PR #58195:
URL: https://github.com/apache/spark/pull/58195#discussion_r4634916513
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/python/ArrowWindowPythonEvaluatorFactory.scala:
##########
@@ -257,6 +258,11 @@ class ArrowWindowPythonEvaluatorFactory(
}
)
val grouping = UnsafeProjection.create(partitionSpec, childOutput)
+ // The bytes are checked first, so a key spelled like its group's first
row costs
+ // one byte comparison and only keys whose bytes differ pay the ordering
comparison;
+ // most checks here compare a row against the first row of the group it
belongs to.
Review Comment:
Done (9a8f6650b72), with your wording: the comment now says the bytes are
checked first so a key spelled like its group first row costs one byte
comparison and only keys whose bytes differ pay the ordering comparison, which
keeps the single byte comparison this loop made before it used the collation,
so it no longer gives a reason that would make WindowExec identical partition
loop look wrong.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/UpdatingSessionsIterator.scala:
##########
@@ -184,29 +194,39 @@ class UpdatingSessionsIterator(
throw SparkException.internalError("The iterator must be sorted by key and
session start!")
}
- private val join = new JoinedRow
private val join2 = new JoinedRow
- private val valueProj = GenerateUnsafeProjection.generate(valuesExpressions,
inputSchema)
- private val restoreProj = GenerateUnsafeProjection.generate(inputSchema,
- groupingWithoutSession.map(_.toAttribute) ++
Seq(sessionExpression.toAttribute) ++
- valuesExpressions.map(_.toAttribute))
-
- private def generateGroupingKey(): InternalRow = {
- val newRow = new
SpecificInternalRow(Seq(sessionExpression.toAttribute).toStructType)
- newRow.update(0, currentSession)
- join(currentKeys, newRow)
- }
+ // The merged session is read from the field appended after the row's own
columns
+ // (field 0 of the right side of join2 below), an ordinal no input column
occupies, so
+ // the rewrite projection cannot resolve it to a buffered row's session
column.
+ private[this] val mergedSessionReference = BoundReference(
+ inputSchema.length, sessionExpression.dataType, sessionExpression.nullable)
+
+ // One projection rewrites each buffered row: every non-session column keeps
its own
+ // ordinal, so each row of a session keeps its own values, including its own
spelling
+ // of a collated grouping key, and only the session column takes the merged
session
+ // from the appended field. The session column is matched by expression ID
rather than
+ // by attribute equality: the session attribute in the grouping list can
carry a
+ // qualifier that the input column lacks, as when the session window is
computed in a
+ // subquery or CTE and grouped outside, and the DISTINCT-aggregate and pandas
+ // grouped-aggregate plans that consume this iterator read the grouping
columns from
+ // the rows it emits.
Review Comment:
Done (7a96ba2be14), with your wording: the comment now names the Python UDAF
aggregation plan together with the one-DISTINCT aggregate and pandas
grouped-aggregate plans as the plans that consume this iterator and read the
grouping columns from the rows it emits, so PythonIncrementalAggregateExec
partial stage no longer reads as outside the list. Thanks also for the
correction on the ExprId note in my earlier reply: an expression ID records the
JVM that created it and ExprId equality compares that too, so an ID created on
an executor would not have collided with a driver-created one; reading the
merged session through the appended bound ordinal stays as the simpler choice
either way.
--
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]