Browse Source

HPCC-14642 Improve error message for invalid distribute by key

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 9 years ago
parent
commit
f062e43409
2 changed files with 30 additions and 1 deletions
  1. 2 1
      ecl/hqlcpp/hqlckey.cpp
  2. 28 0
      ecl/regress/invalidkeydistribute.ecl

+ 2 - 1
ecl/hqlcpp/hqlckey.cpp

@@ -1571,7 +1571,8 @@ ABoundActivity * HqlCppTranslator::doBuildActivityKeyedDistribute(BuildCtx & ctx
     buildSerializedLayoutMember(instance->classctx, indexRecord, "getIndexLayout", numKeyedFields);
 
     OwnedHqlExpr matchExpr = info.getMatchExpr(true);
-    assertex(!matchExpr);
+    if (matchExpr)
+        reportError(expr, ERR_MATCH_KEY_EXACTLY,"Condition on DISTRIBUTE must match the key exactly");
 
     buildInstanceSuffix(instance);
 

+ 28 - 0
ecl/regress/invalidkeydistribute.ecl

@@ -0,0 +1,28 @@
+/*##############################################################################
+
+    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.
+############################################################################## */
+
+namesRecord :=
+            RECORD
+string10        id1;
+string10        id2;
+            END;
+
+namesTable := dataset('x',namesRecord,FLAT);
+
+indexKey := INDEX(namesTable, { id1 }, { id2 }, 'i1');
+
+DISTRIBUTE(namesTable, indexKey, LEFT.id2 = RIGHT.id2);