Au-Miner opened a new pull request, #28384:
URL: https://github.com/apache/flink/pull/28384

   ## What is the purpose of the change
   
   `ArrayContainsFunction` incorrectly used the needle (second argument) data 
type to create the `ElementGetter` and the `equalityEvaluator`'s element field. 
When the array element type differs from the needle type in nullability (e.g., 
`ARRAY<INT NULL>` with a `NOT NULL` needle), the element getter reads array 
data with the wrong type, causing incorrect results or runtime errors.
   
   ## Brief change log
   
   - *[ArrayContainsFunction]* Extract the true element type from 
`CollectionDataType.getElementDataType()` of the first argument (the array) 
instead of reusing the needle's data type.
   - *[ArrayContainsFunction]* Use `elementDataType` for 
`ArrayData.createElementGetter()` and the `"element"` field of the equality 
evaluator; keep `needleDataType` only for the `"needle"` field.
   - *[CollectionFunctionsITCase]* Add test cases for `ARRAY_CONTAINS` where 
the array contains NULL elements and the needle is a NOT NULL literal that is 
not present in the array.
   
   ## Verifying this change
   
   This change added tests in `CollectionFunctionsITCase`:
   
   - `ARRAY_CONTAINS(f4, 0)` where `f4 = ARRAY[1, NULL]` → asserts `false` 
(Table API + SQL)
   - `ARRAY_CONTAINS(ARRAY[1, NULL], 0)` → asserts `false` (SQL only, inline 
array literal)
   
   These tests fail without the fix due to type mismatch in the element getter.
   
   ## Does this pull request potentially affect one of the following parts
   
   - Dependencies (does it add or upgrade a dependency): no
   - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: no
   - The serializers: no
   - The runtime per-record code paths (performance sensitive): no
   - Anything that affects deployment or recovery: no
   - The S3 file system connector: no
   
   ## Documentation
   
   - Does this pull request introduce a new feature? no
   - If not, how is the change documented? Not applicable.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to