Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maropu committed Nov 15, 2019
1 parent a1815ba commit ebec317
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,7 @@ object EliminateSorts extends Rule[LogicalPlan] {

private def isOrderIrrelevantAggs(aggs: Seq[NamedExpression]): Boolean = {
def isOrderIrrelevantAggFunction(func: AggregateFunction): Boolean = func match {
case _: Min => true
case _: Max => true
case _: Count => true
case _: Min | _: Max | _: Count => true
// Arithmetic operations for floating-point values are order-sensitive
// (they are not associative).
case _: Sum | _: Average | _: CentralMomentAgg =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1275,15 +1275,15 @@ class SubquerySuite extends QueryTest with SharedSparkSession {
Seq("float", "double").foreach { typeName =>
Seq("SUM", "AVG", "KURTOSIS", "SKEWNESS", "STDDEV_POP", "STDDEV_SAMP",
"VAR_POP", "VAR_SAMP").foreach { aggName =>
val query1 =
val query =
s"""
|SELECT k, $aggName(v) FROM (
| SELECT k, v
| FROM VALUES (1, $typeName(2.0)), (2, $typeName(1.0)) t(k, v)
| ORDER BY v)
|GROUP BY k
""".stripMargin
assert(getNumSortsInQuery(query1) == 1)
assert(getNumSortsInQuery(query) == 1)
}
}
}
Expand Down

0 comments on commit ebec317

Please sign in to comment.