Sfoglia il codice sorgente

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 9 anni fa
parent
commit
9dda6370b1
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  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;