Explorar o código

HPCC-11098 Allow COMBINE in a thor child query

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday %!s(int64=11) %!d(string=hai) anos
pai
achega
2738caa384

+ 1 - 1
ecl/hqlcpp/hqlhtcpp.cpp

@@ -15059,7 +15059,7 @@ ABoundActivity * HqlCppTranslator::doBuildActivityCombine(BuildCtx & ctx, IHqlEx
     IHqlExpression * transform = expr->queryChild(2);
     IHqlExpression * selSeq = querySelSeq(expr);
 
-    if (targetThor() && !expr->hasAttribute(localAtom))
+    if (targetThor() && !expr->hasAttribute(localAtom) && !insideChildQuery(ctx))
         ERRORAT(queryLocation(expr), HQLERR_ThorCombineOnlyLocal);
 
     CIArray bound;

+ 36 - 0
testing/regress/ecl/combinechild.ecl

@@ -0,0 +1,36 @@
+/*##############################################################################
+
+    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.
+############################################################################## */
+
+idRecord := { unsigned id; };
+
+inRecord := { unsigned id; dataset(idRecord) ids; };
+
+inDs := DATASET([{1,[3,5]},{2,[7,11]}], inRecord);
+
+idRecord tId(unsigned id, delta) := TRANSFORM
+    SELF.id := id + delta;
+END;
+
+inRecord t(inRecord l) := TRANSFORM
+    p1 := PROJECT(l.ids, tId(LEFT.id, 3));
+    p2 := PROJECT(l.ids, tId(LEFT.id, 7));
+
+    SELF.ids := COMBINE(p1, p2, TRANSFORM(idRecord, SELF.id := LEFT.id * RIGHT.id));  // (x+3)*(x+7)
+    SELF := l;
+END;
+
+output(PROJECT(inDs, t(LEFT)));

+ 4 - 0
testing/regress/ecl/key/combinechild.xml

@@ -0,0 +1,4 @@
+<Dataset name='Result 1'>
+ <Row><id>1</id><ids><Row><id>60</id></Row><Row><id>96</id></Row></ids></Row>
+ <Row><id>2</id><ids><Row><id>140</id></Row><Row><id>252</id></Row></ids></Row>
+</Dataset>