Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
91 views
in Technique[技术] by (71.8m points)

How can I aggregate int column to array<int> in flink?

I am exploring a way to achive this like the SQL below in flink.

SELECT a_tag,NEST(type) AS type_arr FROM a GROUP BY a_tag

NEST() is a user defined function whitch aggregate int to array<int>.

But i can't change the output type because the UDF class extends AggregateFunction

Is there any suggestion?Thanks a lot.

question from:https://stackoverflow.com/questions/65644052/how-can-i-aggregate-int-column-to-arrayint-in-flink

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Flink has provided a built-in aggregation function called collect() whitch can handle this situation.

Note that the result type of collect() will be MULTISET


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...