[ 
https://issues.apache.org/jira/browse/FLINK-31377?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

jackylau updated FLINK-31377:
-----------------------------
    Description: 
you can reproduce this error below. and reason is in ARRAY_CONTAINS
{code:java}
if the needle is a Map NOT NULL,and the array has null element.

this will cause getElementOrNull(ArrayData array, int pos) only can handle not 
null. so it throw exception
/*elementGetter = 
ArrayData.createElementGetter(needleDataType.getLogicalType());*/,

{code}
 
{code:java}
// 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()));
}

{code}

  was:
you can reproduce this error below. and reason is in ARRAY_CONTAINS
{code:java}
if the needle is a Map NOT NULL,and the array has null.

this will cause getElementOrNull(ArrayData array, int pos) only can handle not 
null. so it throw exception
/*elementGetter = 
ArrayData.createElementGetter(needleDataType.getLogicalType());*/,

{code}
 
{code:java}
// 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()));
}

{code}


> BinaryArrayData getArray/getMap should Handle null correctly AssertionError: 
> valueArraySize (-6) should >= 0 
> -------------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-31377
>                 URL: https://issues.apache.org/jira/browse/FLINK-31377
>             Project: Flink
>          Issue Type: Bug
>    Affects Versions: 1.18.0
>            Reporter: jackylau
>            Priority: Major
>
> you can reproduce this error below. and reason is in ARRAY_CONTAINS
> {code:java}
> if the needle is a Map NOT NULL,and the array has null element.
> this will cause getElementOrNull(ArrayData array, int pos) only can handle 
> not null. so it throw exception
> /*elementGetter = 
> ArrayData.createElementGetter(needleDataType.getLogicalType());*/,
> {code}
>  
> {code:java}
> // 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()));
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to