Browse Source

HPCC-10006 Stop compound aggregation of CHOOSEN with start count

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 11 years ago
parent
commit
9214941864
4 changed files with 58 additions and 0 deletions
  1. 14 0
      ecl/hqlcpp/hqlttcpp.cpp
  2. 5 0
      ecl/regress/issue10006.ecl
  3. 30 0
      testing/ecl/indexagg.ecl
  4. 9 0
      testing/ecl/key/indexagg.xml

+ 14 - 0
ecl/hqlcpp/hqlttcpp.cpp

@@ -3992,6 +3992,20 @@ void CompoundSourceTransformer::analyseGatherInfo(IHqlExpression * expr)
                 if (parentExtra->hasAnyLimit() && !isSimpleCountExists)
                     break;
 
+                //We either have a limit or choosen as the input
+                if (parentExtra->isCloned)
+                {
+                    assertex(isSimpleCountExists);
+                    //Too complicated if the limit is local
+                    if ((targetClusterType == ThorLCRCluster) && dataset->hasAttribute(localAtom))
+                        break;
+
+                    //CHOOSEN(ds, x, <n>)
+                    if ((dataset->getOperator() == no_choosen) && queryRealChild(dataset, 2))
+                        break;
+                }
+
+
                 node_operator newOp = no_none;
                 node_operator parentOp = parentExtra->sourceOp;
                 if (queryRealChild(expr, 3))

+ 5 - 0
ecl/regress/issue10006.ecl

@@ -0,0 +1,5 @@
+i := index({ unsigned id }, {}, 'i');
+
+k := i(id = 0);
+c := choosen(k, 100, 100);
+output(count(c));

+ 30 - 0
testing/ecl/indexagg.ecl

@@ -0,0 +1,30 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+############################################################################## */
+
+//UseStandardFiles
+//UseIndexes
+
+IMPORT Std;
+
+
+sequential(
+
+output(max(choosen(DG_FetchIndex1, 1,3), Fname));
+output(min(choosen(DG_FetchIndex1, 1,3), Fname));
+
+output(count(choosen(DG_FetchIndex1, 1,3)))
+);

+ 9 - 0
testing/ecl/key/indexagg.xml

@@ -0,0 +1,9 @@
+<Dataset name='Result 1'>
+ <Row><Result_1>John           </Result_1></Row>
+</Dataset>
+<Dataset name='Result 2'>
+ <Row><Result_2>John           </Result_2></Row>
+</Dataset>
+<Dataset name='Result 3'>
+ <Row><Result_3>1</Result_3></Row>
+</Dataset>