You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "wangpeibin (JIRA)" <ji...@apache.org> on 2019/02/21 07:08:00 UTC

[jira] [Created] (FLINK-11706) Add the SumFunction to support KeyedStream.sum with field which is array

wangpeibin created FLINK-11706:
----------------------------------

             Summary: Add the SumFunction to support KeyedStream.sum with field which is array 
                 Key: FLINK-11706
                 URL: https://issues.apache.org/jira/browse/FLINK-11706
             Project: Flink
          Issue Type: Improvement
          Components: DataStream API
            Reporter: wangpeibin
            Assignee: wangpeibin


The goal is to implement a KeyedStream API to sum with *the field which is array*.

The example code with like:
{code}
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
DataStream<Tuple2<Long, Integer[]>> src = env.fromCollection(Arrays.asList(
   new Tuple2<>(1L, new Integer[]{2, 4}),
   new Tuple2<>(1L, new Integer[]{3, 6}),
   new Tuple2<>(1L, new Integer[]{4, 8}),
   new Tuple2<>(2L, new Integer[]{2, 4}),
   new Tuple2<>(2L, new Integer[]{3, 6}),
   new Tuple2<>(2L, new Integer[]{4, 8})
));

src.keyBy(0)
.sum(1}) 
.print();
env.execute();
{code}
right now this job will throw out exception:
{code:java}
java.lang.RuntimeException: DataStream cannot be summed because the class Integer[] does not support the + operator.
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)