Explorar o código

Merge pull request #8721 from ghalliday/issue15639

HPCC-15639 SORT cannot be removed before an aggregate of a COUNT project

Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman %!s(int64=9) %!d(string=hai) anos
pai
achega
9dda6370b1
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      ecl/hql/hqlopt.cpp

+ 6 - 0
ecl/hql/hqlopt.cpp

@@ -497,6 +497,12 @@ IHqlExpression * CTreeOptimizer::optimizeAggregateUnsharedDataset(IHqlExpression
     case no_fetch:
     case no_transformebcdic:
     case no_transformascii:
+        if (expr->hasAttribute(_countProject_Atom))
+        {
+            //Cannot remove a sort before a count project - because subsequent code may be aggregating or filtering
+            //on fields that contain values derived from the COUNTER
+            return LINK(expr);
+        }
         if (childIsSimpleCount && !isPureActivity(expr))
             childIsSimpleCount = false;
         break;