Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-9887

Throw IllegalArgumentException when building Row with logical types with Invalid input

Details

    • Bug
    • Status: Resolved
    • P2
    • Resolution: Fixed
    • None
    • 2.22.0
    • sdk-java-core

    Description

      schema.logicaltypes.FixedBytes logical type expects an argument - the length of the byte[].

      When an invalid input value (with length < expectedLength) is provided while building the Row with FixedBytes logical type, IllegalArgumentException is expected. But, the Exception is not thrown. The below code illustrates the behaviour:

       Schema schema = Schema.builder().addLogicalTypeField("char", FixedBytes.of(10)).build();
       byte[] byteArray = {1, 2, 3, 4, 5};
       Row row = Row.withSchema(schema).withFieldValue("char", byteArray).build();
       System.out.println(Arrays.toString(row.getLogicalTypeValue("char", byte[].class)));
      

      The above code prints "[1, 2, 3, 4, 5]" with length 5 to the console, whereas the expected length of FixedBytes, is 10.

      The code is run on the master branch.

      The behaviour is as expected with 2.20.0 release.

       

      Attachments

        Issue Links

          Activity

            People

              rahul8383 Rahul Patwari
              rahul8383 Rahul Patwari
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 3h 50m
                  3h 50m