Hi Daniele, 

It's a good idea to implement a UDF[1] by referring to the ArrayAggFunction[2] 
in Flink.

I don't understand what "I don't get how RowData comes into play" means. 
Could you clarify it?

Best,
Jiabao

[1] 
https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/functions/udfs/#aggregate-functions
[2] 
https://github.com/apache/flink/blob/28ae3ae65d13b98dc28b919ef75c14780c512618/flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/aggregate/ArrayAggFunction.java

On 2024/10/24 08:34:32 Daniele Parmeggiani wrote:
> Hi Hanyu Zheng 👋
> 
> I've actually included the function into a UDF jar, hoping I could get
> away with not forking Flink itself.
> Do you think that'll work?
> 
> In my SQL script I import the function like this:
> ```sql
> create temporary function ArrayAggFunction
>     as 'eu.spaziodati.cp.flink.funcs.ArrayAggFunction'
>     using jar '<file:///opt/flink/plugins/cp-funcs.jar';>
> ```
> 
> Then I use it like this:
> ```sql
> select `...`, ArrayAggFunction(row(...))
> ```
> 
> So the fact that a Row is being passed into the function does not
> surprise me, but I don't get how RowData comes into play.
> 
> 
> Daniele
> 
> 
> 
> On October 24, 2024, user <user@flink.apache.org> wrote:
> > Hi Daniele Parmeggiani,
> >
> > I have some ideas regarding the issue. From the exception:
> >
> > java.lang.ClassCastException: class org.apache.flink.types.Row cannot
> > be cast to class org.apache.flink.table.data.RowData
> > This error clearly indicates that the code is trying to cast a Row
> > object to a RowData object, which suggests that the input data being
> > processed is of type Row. However, the backported ARRAY_AGG function
> > expects RowData. The type mismatch between Row and RowData might be
> > causing the error.
> >
> > We need to confirm whether the data type passed to ARRAY_AGG is the
> > correct one. Additionally, the input and output strategy should be
> > defined in BuiltInFunctionDefinitions — we should first define the
> > input and output types and then let the function use them.
> >
> > It’s possible that checking the type in the wrong place and passing an
> > incorrect data type is leading to this issue.
> >
> >
> > --
> >
> >  <https://www.confluent.io>
> > Hanyu (Peter) Zheng he/him/hisSoftware Engineer+1 (213) 431-7193
> > <tel:+1+(213)+431-7193>
> > Follow us:
> > <https://www.confluent.io/blog?utm_source=footer&utm_medium=email&utm_campaign=ch.email-
> > signature_type.community_content.blog>
> > <https://twitter.com/ConfluentInc> <https://www.linkedin.com/in/hanyu-
> > peter-zheng/> <https://slackpass.io/confluentcommunity>
> > <https://youtube.com/confluent>
> > <https://www.confluent.io/get-started?utm_campaign=tm.fm-
> > apac_cd.inbound&utm_source=gmail&utm_medium=organic>
> >
> >
> 

Reply via email to