Re: Scala Table API with Java POJO

Posted by Dong-iL, Kim on
URL: http://deprecated-apache-flink-user-mailing-list-archive.369.s1.nabble.com/Scala-Table-API-with-Java-POJO-tp8219p8224.html

Hi Timo.
I’m using scala API.
There is no error with java API.
my code snippet is this.

dataSet.toTable
                .groupBy(“id")
                .select(‘id, ‘amount.sum as ‘amount)
                .where(‘amount > 0)
                .toDataSet[TestPojo]
                .print()

Thanks.

> On Aug 1, 2016, at 5:50 PM, Timo Walther <[hidden email]> wrote:
>
> Hi Kim,
>
> as the exception says: POJOs have no deterministic field order. You have to specify the order during the DataSet to Table conversion:
>
> Table table = tableEnv.fromDataSet(pojoDataSet, "pojoField as a, pojoField2 as b");
>
> I hope that helps. Otherwise it would help if you could supply a code snippet of your program.
>
> Timo
>
> Am 01/08/16 um 10:19 schrieb Dong-iL, Kim:
>> my flink ver is 1.0.3.
>> thanks.
>>
>>> On Aug 1, 2016, at 5:18 PM, Dong-iL, Kim <[hidden email]> wrote:
>>>
>>> I’ve create a program using table API and get an exception like this.
>>> org.apache.flink.api.table.ExpressionException: You cannot rename fields upon Table creation: Field order of input type PojoType<….> is not deterministic.
>>> There is an error not in java program, but in scala program.
>>> how can I use java POJO with scala Table API.
>>>
>
>
> --
> Freundliche Grüße / Kind Regards
>
> Timo Walther
>
> Follow me: @twalthr
> https://www.linkedin.com/in/twalthr
>