Uploaded image for project: 'HPCC'
  1. HPCC
  2. HPCC-17390

MAP strange behaviour for unicode value

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Not specified
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.4.0
    • Component/s: None
    • Labels:
      None

      Description

      Some strange behaviour by MAP function.Running:

      IMPORT Std;
      IMPORT Util.Files;

      FilePath := 'MyTestFile';
      FileLayout :=

      { utf8 MyValue }

      ;
      MyFile := Files.LoadCsvFile(FilePath, FileLayout);
      y := MyFile[1].MyValue;

      UseMap(UTF8 myValue) := FUNCTION
      RETURN MAP(
      myValue = U'Permanent' => 2,
      //Std.Uni.CompareAtStrength(myValue, U'SomethingElse' , 5) = 0 => 4,
      myValue = U'Fixed term contract' => 3,
      myValue = U'Fixed Term' => 3,
      1
      );
      END;

      UseMap( y );

      returns 1 as the result.

      If I uncomment the line with Std.Uni, the result is 2.
      If I comment that line again, the result goes back to 1, but then I comment out line "myValue = U'Fixed term contract' => 3," and the result is 2 again. I then add another line "myValue = U'Whatever' => 5," and the result is 1 again.

      y comes from a file and comparing using other methods indicates it has the value U'Permanent' and the result should always be 2. But even if I shouldn't be using "=" for unicode comparison, at least MAP should be consistent, and the result should not depend on whether an additional condition is there.

      For reference, here are the other methods I used to compare:

      UseCase(UTF8 myValue) := FUNCTION
      RETURN CASE(myValue,
      U'Permanent' => 2,
      U'Fixed term contract' => 3,
      U'Fixed Term' => 3,
      1
      );
      END;

      x := u'Permanent';
      x = y; // true
      Std.Uni.CompareAtStrength(x,y,5) = 0; // true
      IF(y = U'Permanent', 2, 1); // 2
      IF(Std.Uni.CompareAtStrength(x,y,5) = 0, 2, 1); // 2
      UseCase( x ); // 2
      UseCase( y ); // 2
      UseMap( x ); // 2

      So, based on all this the result of UseMap( y ) should always be 2.

        Attachments

          Activity

            People

            • Assignee:
              ghalliday Gavin Halliday
              Reporter:
              nemanjaperovic Nemanja Perovic
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: