flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dongwon Kim <eastcirc...@gmail.com>
Subject Re: How to split tuple2 returned by UDAF into two columns in a result table
Date Wed, 20 Mar 2019 04:09:00 GMT
Hi Kurt,
You're right; It is table function like "mytablefunc(col1, col2, col3) as
(col4, col5)".
I've got to define a custom UDTF for that purpose.
Thanks,

- Dongwon

On Wed, Mar 20, 2019 at 12:04 PM Kurt Young <ykt836@gmail.com> wrote:

> Hi Dongwon,
>
> AFAIK, Flink doesn't support the usage like "myscalar(col1, col2, col3) as
> (col4, col5)". Am I missing something?
>
> If you want to split Tuple2 into two different columns, you can use UDTF.
>
> Best,
> Kurt
>
>
> On Wed, Mar 20, 2019 at 9:59 AM Dongwon Kim <eastcirclek@gmail.com> wrote:
>
>> Hi,
>>
>> I want to split Tuple2 returned by AggregateFunction.getValue into two
>> different columns in a resultant table.
>>
>> Let's consider the following example where myudaf returns Tuple2<Boolean,
>> Boolean>:
>>
>>   Table table2 = table1
>>       .window(Slide.over("3.rows").every("1.rows").on("time").as("w"))
>>       .groupBy("w, name")
>>       .select("name, myudaf(col1, col2, col3) as (col4, col5)")
>>
>> Then table2.printSchema() returns (w/ Flink 1.7.2)
>>
>>   root
>>     |-- name: String
>>     |-- col4: Java Tuple2<Boolean, Boolean>
>>
>> whereas my expectation is
>>
>>   root
>>     |-- name: String
>>     |-- col4: Boolean
>>     |-- col5: Boolean
>>
>> When I define a scalar function which returns Tuple2 and use like
>> "myscalar(col1, col2, col3) as (col4, col5)", it works as expected.
>>
>> Is there a possible way of splitting the tuple into two different columns
>> in Flink-1.7.2?
>> If not, do I have to define an additional UDF in order to flatten the
>> tuple? or there's already one I can make use of?
>>
>> - Dongwon
>
>

Mime
View raw message