[ https://issues.apache.org/jira/browse/FLINK-35275?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17842395#comment-17842395 ]
PengFei Li commented on FLINK-35275: ------------------------------------ [~twalthr] Could you help confirm if this is a bug? If so, I'd like to fix it. > ArrayContainsFunction uses wrong DataType to create element getter > ------------------------------------------------------------------ > > Key: FLINK-35275 > URL: https://issues.apache.org/jira/browse/FLINK-35275 > Project: Flink > Issue Type: Bug > Components: Table SQL / Runtime > Affects Versions: 1.16.0 > Reporter: PengFei Li > Priority: Minor > > > In ArrayContainsFunction, elementGetter is used to get elements of an array, > but it's created from the needle data type rather than the element data type > which will lead to wrong results. > {code:java} > public ArrayContainsFunction(SpecializedContext context) { > super(BuiltInFunctionDefinitions.ARRAY_CONTAINS, context); > final DataType needleDataType = > context.getCallContext().getArgumentDataTypes().get(1); > elementGetter = > ArrayData.createElementGetter(needleDataType.getLogicalType()); > > } {code} > For example, the following sql returns true, but the expected is false. The > element type is nullable int, and the needle type is non-nullable int. Using > the needle type to create element getter will convert the NULL element to 0, > so the result returns true. > {code:java} > SELECT ARRAY_CONTAINS(ARRAY[1, NULL], 0){code} > > -- This message was sent by Atlassian Jira (v8.20.10#820010)