You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Md Kamaruzzaman (JIRA)" <ji...@apache.org> on 2017/07/26 14:33:00 UTC

[jira] [Commented] (FLINK-6909) Flink should support Lombok POJO

    [ https://issues.apache.org/jira/browse/FLINK-6909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16101729#comment-16101729 ] 

Md Kamaruzzaman commented on FLINK-6909:
----------------------------------------

I have a simple ETL process which read CSV file and write it to a file as JSON.

Here is the Pojo which maps the CSV file:

@Getter
@Setter
@NoArgsConstructor
public class ImdbRating{
.
.
}

Here @Getter, @Setter, @NoArgsConstructor are annotations from lombok which will generate getter, setter and default constructor in the bytecode. 

Here is the code snippet to load csv data:

final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
        env.registerType(ImdbRating.class);
        DataSource<ImdbRating> dataSource = env.readCsvFile(sourceFile.getPath()).ignoreFirstLine()
                .ignoreInvalidLines().pojoType(ImdbRating.class, "position", "imdbId", "created", "modified", "description", "title", "titleType", "directors",
                        "rating", "imdbRating", "runtime", "year", "genres", "numberOfVotes", "releaseDate", "url");

Running this gives the following exceptions:

java.lang.ClassCastException: org.apache.flink.api.java.typeutils.GenericTypeInfo cannot be cast to org.apache.flink.api.java.typeutils.PojoTypeInfo
	at org.apache.flink.api.java.io.CsvReader.pojoType(CsvReader.java:318)


If I remove the lombok annotations and write getter in the class, then it works fine. 

I have debugged a bit and it looks like the class 'TypeExtractor' fails to recognize ImdbLoader as a valid Java POJO when lombok annotations are used.


> Flink should support Lombok POJO
> --------------------------------
>
>                 Key: FLINK-6909
>                 URL: https://issues.apache.org/jira/browse/FLINK-6909
>             Project: Flink
>          Issue Type: Wish
>          Components: Type Serialization System
>            Reporter: Md Kamaruzzaman
>            Priority: Minor
>             Fix For: 1.2.1
>
>
> Project lombok helps greatly to reduce boilerplate Java Code. 
> It seems that Flink does not accept a lombok POJO as a valid pojo. 
> e.g. Here is a POJO defined with lombok:
> @Getter
> @Setter
> @NoArgsConstructor
> public class SimplePojo
> Using this Pojo class to read from CSV file throws this exception:
> Exception in thread "main" java.lang.ClassCastException: org.apache.flink.api.java.typeutils.GenericTypeInfo cannot be cast to org.apache.flink.api.java.typeutils.PojoTypeInfo
> It would be great if flink supports lombok POJO.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)