فهرست منبع

HPCC-14086 Do not generate case via array if default is not constant

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 9 سال پیش
والد
کامیت
934da87f06
2فایلهای تغییر یافته به همراه33 افزوده شده و 1 حذف شده
  1. 1 1
      ecl/hqlcpp/hqlcppcase.cpp
  2. 32 0
      ecl/regress/issue14086.ecl

+ 1 - 1
ecl/hqlcpp/hqlcppcase.cpp

@@ -1054,7 +1054,7 @@ bool HqlCppCaseInfo::canBuildArrayLookup(const CHqlBoundExpr & test)
 
 bool HqlCppCaseInfo::queryBuildArrayLookup(BuildCtx & ctx, const CHqlBoundTarget & target, const CHqlBoundExpr & test)
 {
-    if (canBuildArrayLookup(test) && canBuildStaticList(resultType))
+    if (canBuildArrayLookup(test) && canBuildStaticList(resultType) && defaultValue->isConstant())
     {
         //MORE: Also support this for high density tables that don't start at 0... - checking upper and lower bounds
         ITypeInfo * condType = test.queryType()->queryPromotedType();

+ 32 - 0
ecl/regress/issue14086.ecl

@@ -0,0 +1,32 @@
+l2n(string1 letter) := case(letter,
+                            'A' => 0,       'K' => 10,       'U' => 20,
+                            'B' => 1,       'L' => 11,       'V' => 21,
+                            'C' => 2,       'M' => 12,       'W' => 22,
+                            'D' => 3,       'N' => 13,       'X' => 23,
+                            'E' => 4,       'O' => 14,       'Y' => 24,
+                            'F' => 5,       'P' => 15,       'Z' => 25,
+                            'G' => 6,       'Q' => 16,
+                            'H' => 7,       'R' => 17,
+                            'I' => 8,       'S' => 18,
+                            'J' => 9,       'T' => 19,
+                            error('Valid letter not provided: [' + letter + ']'));
+                            // -1);       // works if not using error
+
+sampleExternals :=
+  dataset([
+    {'B000'}
+  ],{string4 db_ext});
+
+// ds0 := sampleExternals;     // works if read inline
+ds0 := dataset('~jira::sample',{string4 db_ext},thor);
+
+ds := project(ds0,
+              transform({string4 orig, unsigned4 db_int},
+                        self.orig := left.db_ext,
+                        self.db_int := l2n(left.db_ext[1]),
+                        ));
+
+sequential (
+  output (sampleExternals,,'~jira::sample',overwrite),
+  output(ds,all)
+);