nateab opened a new pull request, #27511:
URL: https://github.com/apache/flink/pull/27511

   …gument types
   
   ##  What is the purpose of the change
   
     This pull request fixes a ClassCastException that occurs when a UDF 
expects Array<RowData> (or similar complex nested types) as a parameter. The 
issue was that ScalarFunctionCallGen.prepareFunctionArgs()
     incorrectly treated nested complex types like arrays containing RowData as 
RAW types instead of ROW types, causing a "GenericRowData cannot be cast to 
RawValueData" exception.
   
     The root cause was that the code only examined the function signature's 
type information and used fromLegacyInfoToDataType() for non-generic types, 
which incorrectly handled nested complex types. The fix changes
     the approach to use the operand's logical type as the source of truth for 
the data type structure, then bridges to the expected conversion class from the 
parameter type.
   
   ##  Brief change log
   
     - Modified prepareFunctionArgs() in ScalarFunctionCallGen.scala to derive 
DataType from the operand's logical type and bridge to the parameter's 
conversion class, rather than relying on fromLegacyInfoToDataType()
      which mishandled nested complex types
     - Added ArrayOfRowsUdf test function that accepts Array<Row> as a parameter
     - Added testUdfWithArrayOfRowsParameter() integration test to verify the 
fix
   
   ##  Verifying this change
   
     This change added tests and can be verified as follows:
   
     - Added ArrayOfRowsUdf scalar function in userDefinedScalarFunctions.scala 
that takes Array<ROW<f0 INT, f1 STRING>> and returns the array length
     - Added testUdfWithArrayOfRowsParameter() integration test in 
CalcITCase.scala that verifies UDFs with Array<Row> parameters work correctly 
without ClassCastException
   
   ##  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: JobManager (and its 
components), Checkpointing, Kubernetes/Yarn, ZooKeeper: no
     - The S3 file system connector: no
   
   ##  Documentation
   
     - Does this pull request introduce a new feature? no
     - If yes, how is the feature 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