Browse Source

Merge pull request #8372 from ghalliday/issue15112

HPCC-15112 Fix incorrect distribution match

Reviewed-By: Shamser Ahmed <shamser.ahmed@lexisnexis.co.uk>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 9 years ago
parent
commit
67b9c3d32b
2 changed files with 33 additions and 2 deletions
  1. 2 2
      ecl/hql/hqlmeta.cpp
  2. 31 0
      ecl/regress/issue15112.ecl

+ 2 - 2
ecl/hql/hqlmeta.cpp

@@ -1664,7 +1664,7 @@ static bool checkDistributedCoLocally(IHqlExpression * distribute1, IHqlExpressi
     unsigned match1 = sort1.find(*distribute1->queryBody());
     unsigned match2 = sort2.find(*distribute2->queryBody());
     if ((match1 != NotFound) || (match2 != NotFound))
-        return match1 == match2;
+        return (match1 == match2);
 
     node_operator op = distribute1->getOperator();
     if (op != distribute2->getOperator())
@@ -1685,7 +1685,7 @@ static bool checkDistributedCoLocally(IHqlExpression * distribute1, IHqlExpressi
     }
 
     if (max == 0)
-        return true;
+        return (distribute1->queryBody() == distribute2->queryBody());
 
     for (unsigned idx = 0; idx < max; idx++)
     {

+ 31 - 0
ecl/regress/issue15112.ecl

@@ -0,0 +1,31 @@
+/*##############################################################################
+    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.
+############################################################################## */
+
+layout := {
+    unsigned u1,
+};
+
+ds := nofold(dataset([{1},{2}], layout));
+ds2 := nofold(dataset([{2},{3}], layout));
+
+dsDist := distribute(ds, u1 - 1);
+dsDist2 := distribute(ds2, u1 - 2);
+
+j1 := join(dsDist, dsDist2,
+           left.u1 = right.u1,
+           transform(left));
+
+output(j1);