Explorar o código

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

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday %!s(int64=9) %!d(string=hai) anos
pai
achega
da77159849
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;