Browse Source

HPCC-13081 Ignore ,MERGE on non-grouping Aggregate

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 10 years ago
parent
commit
c31860bc6b

+ 4 - 0
ecl/hqlcpp/hqlttcpp.cpp

@@ -3469,6 +3469,10 @@ IHqlExpression * ThorHqlTransformer::normalizeMergeAggregate(IHqlExpression * ex
 
     //If locally distributed then don't do anything
     OwnedHqlExpr noMerge = removeAttribute(expr, mergeAtom);
+    //This transformation only works for grouped aggregation
+    if (!groupBy || groupBy->isAttribute())
+        return noMerge.getClear();
+
     if (!translator.targetThor() || expr->hasAttribute(localAtom) || isPartitionedForGroup(dataset, groupBy, true))
         return noMerge.getClear();
 

+ 64 - 0
testing/regress/ecl/issue13081.ecl

@@ -0,0 +1,64 @@
+/*##############################################################################
+
+    HPCC SYSTEMS software Copyright (C) 2015 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.
+############################################################################## */
+
+//Test only makes any sense on thor, test roxie to ensure attributes are ignored
+//nohthor
+
+DataRec := RECORD
+    UNSIGNED2   f1;
+END;
+
+dsTemp := DATASET
+    (
+        [1, 2, 3, 4, 5],
+        DataRec
+    );
+
+ds := DISTRIBUTE(dsTemp);
+
+TableRec := RECORD
+    REAL8       average := AVE(GROUP, ds.f1);
+END;
+
+r1 := TABLE(ds, TableRec, FEW);
+OUTPUT(r1, NAMED('Few'));
+
+r2 := TABLE(ds, TableRec, FEW, MERGE);
+OUTPUT(r2, NAMED('FewMerge'));
+
+r1x := TABLE(ds, TableRec, f1 DIV 2, FEW);
+OUTPUT(r1x, NAMED('FewX'));
+
+r2x := TABLE(ds, TableRec, f1 DIV 2, FEW, MERGE);
+OUTPUT(r2x, NAMED('FewMergeX'));
+
+dsTemp2 := NOFOLD(DATASET
+    (
+        [1, 1, 1],
+        DataRec
+    ));
+
+TableRec2 := RECORD
+    REAL8       average := AVE(GROUP, dsTemp2.f1);
+END;
+
+r3 := TABLE(dsTemp2, TableRec2, MERGE);
+OUTPUT(r3, NAMED('Merge2'));
+
+r3x := TABLE(dsTemp2, TableRec2, f1, MERGE);
+OUTPUT(r3x, NAMED('Merge2x'));
+

+ 22 - 0
testing/regress/ecl/key/issue13081.xml

@@ -0,0 +1,22 @@
+<Dataset name='Few'>
+ <Row><average>3.0</average></Row>
+</Dataset>
+<Dataset name='FewMerge'>
+ <Row><average>3.0</average></Row>
+</Dataset>
+<Dataset name='FewX'>
+ <Row><average>1.0</average></Row>
+ <Row><average>2.5</average></Row>
+ <Row><average>4.5</average></Row>
+</Dataset>
+<Dataset name='FewMergeX'>
+ <Row><average>1.0</average></Row>
+ <Row><average>2.5</average></Row>
+ <Row><average>4.5</average></Row>
+</Dataset>
+<Dataset name='Merge2'>
+ <Row><average>1.0</average></Row>
+</Dataset>
+<Dataset name='Merge2x'>
+ <Row><average>1.0</average></Row>
+</Dataset>