MosheCh
MosheCh

Reputation: 99

Writing null values into parquet file with mapper

I am trying to do the following:

    String x=null;
    Group group = factory.newGroup()
          .append("x", x);
context.write(null,group)


With the following scheme:

String writeSchema = "message example {\n" +
  "optional binary x;\n" +
  "}";<br>

But I get NullPointerException in the append line. Maybe I am missing something in the scheme?

Upvotes: 1

Views: 611

Answers (1)

maxmithun
maxmithun

Reputation: 1137

Here the String object itself is null. While writing to the filesystem it tries to get the value of the object which is causing the NullPointerExeception.

String x =null;
System.out.println(x.toString()); // Will cause a NullPointerExeception

Similarly any function call to the object will cause the same.

Try using String x ="null" instead

Upvotes: 2

Related Questions