Browse Source

HPCC-20291 Catch illegal SKIP inside a ROW transform

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 6 years ago
parent
commit
aea32aca90
3 changed files with 23 additions and 1 deletions
  1. 1 1
      ecl/hqlcpp/hqlcerrors.hpp
  2. 9 0
      ecl/hqlcpp/hqlhtcpp.cpp
  3. 13 0
      ecl/regress/issue20291.ecl

+ 1 - 1
ecl/hqlcpp/hqlcerrors.hpp

@@ -454,7 +454,7 @@
 #define HQLERR_InputsAreTooComplexToUpdate_Text "UPDATE cannot be used when the inputs names are not globally constant"
 #define HQLERR_ThorDenormOnlyLeftOuterJoin_Text "THOR currently only supports LEFT OUTER denormalize"
 #define HQLERR_ThorDenormNoFeatureX_Text        "THOR does not support DENORMALIZE(%s)"
-#define HQLERR_SkipNotValidHere_Text            "SKIP cannot be used here.  It is only valid directly with a transform"
+#define HQLERR_SkipNotValidHere_Text            "SKIP cannot be used here.  It is only valid directly with a DATASET transform"
 #define HQLERR_CsvNotSupportTableSet_Text       "Cannot read tables/datasets from a csv file"
 #define HQLERR_ExpectedConstantWorkunit_Text    "Argument %s to #workunit must be a constant"
 #define HQLERR_ExpectedConstantDebug_Text       "Argument %s to #debug must be a constant"

+ 9 - 0
ecl/hqlcpp/hqlhtcpp.cpp

@@ -15476,6 +15476,15 @@ ABoundActivity * HqlCppTranslator::doBuildActivityProject(BuildCtx & ctx, IHqlEx
             doTransform(func.ctx, transform, selfCursor);
             buildReturnRecordSize(func.ctx, selfCursor);
         }
+        else if (op == no_projectrow)
+        {
+            if (transform->getOperator() == no_skip)
+                throwError(HQLERR_SkipNotValidHere);
+
+            BoundRow * selfCursor = buildTransformCursors(func.ctx, transform, dataset, nullptr, instance->activityExpr, selSeq);
+            doTransform(func.ctx, transform, selfCursor);
+            buildReturnRecordSize(func.ctx, selfCursor);
+        }
         else
             buildTransformBody(func.ctx, transform, dataset, NULL, instance->activityExpr, selSeq);
     }

+ 13 - 0
ecl/regress/issue20291.ecl

@@ -0,0 +1,13 @@
+ds := DATASET([1,2,3,4,5], {UNSIGNED1 n});
+
+res := PROJECT
+    (
+        NOFOLD(ds[1]),
+        TRANSFORM
+            (
+                {STRING s},
+                SELF.s := IF(LEFT.n % 2 = 0, SKIP, 'x') + '-' + IF(LEFT.n % 2 = 1, SKIP, 'y')
+            )
+    );
+
+OUTPUT(res);