Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/7392#discussion_r34661517
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateOrdering.scala
---
@@ -46,30 +46,47 @@ object GenerateOrdering extends
CodeGenerator[Seq[SortOrder], Ordering[InternalR
protected def create(ordering: Seq[SortOrder]): Ordering[InternalRow] = {
val ctx = newCodeGenContext()
- val comparisons = ordering.zipWithIndex.map { case (order, i) =>
--- End diff --
In interpreted mode, we use the same expression to eval 2
[rows](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/rows.scala#L164-L165),
which means we only keep one copy of mutable states for that expression.
However, in `GenerateOrdering`, we call `order.child.gen(ctx)` twice and thus
make 2 copy of mutable states for that expression. This is inconsistent, and
may return different compare result.
However, should we allow stateful expressions in order by?
cc @davies @rxin
---
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]