Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-31377

BinaryArrayData getArray/getMap should Handle null correctly AssertionError: valueArraySize (-6) should >= 0

    XMLWordPrintableJSON

Details

    Description

      you can reproduce this error below. and reason is in ARRAY_CONTAINS

      if the needle is a Map NOT NULL,and the array has null element.
      
      this bellowing will cause getElementOrNull(ArrayData array, int pos) only can handle not null. so it throw exception
      /*elementGetter = ArrayData.createElementGetter(needleDataType.getLogicalType());*/,
      
      

       

      // code placeholder
      Stream<TestSetSpec> getTestSetSpecs() {
          return Stream.of(
                  TestSetSpec.forFunction(BuiltInFunctionDefinitions.ARRAY_CONTAINS)
                          .onFieldsWithData(
                                  new Map[] {
                                      null,
                                      CollectionUtil.map(entry(1, "a"), entry(2, "b")),
                                      CollectionUtil.map(entry(3, "c"), entry(4, "d")),
                                  },
                                  null)
                          .andDataTypes(
                                  DataTypes.ARRAY(DataTypes.MAP(DataTypes.INT(), DataTypes.STRING())),
                                  DataTypes.STRING())
                          .testResult(
                                  $("f0").arrayContains(
                                                  CollectionUtil.map(entry(3, "c"), entry(4, "d"))),
                                  "ARRAY_CONTAINS(f0, MAP[3, 'c', 4, 'd'])",
                                  true,
                                  DataTypes.BOOLEAN()));
      }
      
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jackylau Jacky Lau
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: