Skip to content

Conversation

@nezihyigitbasi
Copy link
Contributor

When dumping a parquet map with parquet-cat --json it throws a class cast exception as it doesn't properly handle all map key types.

java.lang.ClassCastException: [B cannot be cast to java.lang.String
    at org.apache.parquet.tools.read.SimpleMapRecord.toJsonObject(SimpleMapRecord.java:34)
    at org.apache.parquet.tools.read.SimpleRecord.toJsonValue(SimpleRecord.java:119)
    at org.apache.parquet.tools.read.SimpleRecord.toJsonObject(SimpleRecord.java:112)
    at org.apache.parquet.tools.read.SimpleRecord.prettyPrintJson(SimpleRecord.java:106)
    at org.apache.parquet.tools.command.CatCommand.execute(CatCommand.java:76)
    at org.apache.parquet.tools.Main.main(Main.java:222)
[B cannot be cast to java.lang.String

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should use the BinaryNode that is used elsewhere to convert a Binary or byte[] to JSON. That will base64-encode the data so it is still binary rather than creating an array node.

@nezihyigitbasi
Copy link
Contributor Author

@rdblue updated, thanks.

@rdblue
Copy link
Contributor

rdblue commented Sep 8, 2015

Sorry, I should have mentioned this earlier: can you also add a test or two that exercises the new keyToString function?

@nezihyigitbasi
Copy link
Contributor Author

@rdblue yeah totally forgot to add them. updated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you forgot to add a license header to this file and that's causing Travis CI to fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@rdblue
Copy link
Contributor

rdblue commented Sep 16, 2015

Just tried to merge, but the format is wrong. Could you remove the square brackets from this PR title? Thanks!

@nezihyigitbasi nezihyigitbasi changed the title [PARQUET-360] Handle all map key types with cat tool's json dump PARQUET-360: Handle all map key types with cat tool's json dump Sep 17, 2015
@nezihyigitbasi
Copy link
Contributor Author

@rdblue updated the title.

@julienledem
Copy link
Member

looks good to me.
@wesleypeck did you have comments?

@asfgit asfgit closed this in 0637e2f Sep 17, 2015
rdblue pushed a commit to rdblue/parquet-mr that referenced this pull request Jul 13, 2016
When dumping a parquet map with `parquet-cat --json` it throws a class cast exception as it doesn't properly handle all map key types.

```
java.lang.ClassCastException: [B cannot be cast to java.lang.String
	at org.apache.parquet.tools.read.SimpleMapRecord.toJsonObject(SimpleMapRecord.java:34)
	at org.apache.parquet.tools.read.SimpleRecord.toJsonValue(SimpleRecord.java:119)
	at org.apache.parquet.tools.read.SimpleRecord.toJsonObject(SimpleRecord.java:112)
	at org.apache.parquet.tools.read.SimpleRecord.prettyPrintJson(SimpleRecord.java:106)
	at org.apache.parquet.tools.command.CatCommand.execute(CatCommand.java:76)
	at org.apache.parquet.tools.Main.main(Main.java:222)
[B cannot be cast to java.lang.String
```

Author: Nezih Yigitbasi <nyigitbasi@netflix.com>

Closes apache#259 from nezihyigitbasi/parquet-cat-json and squashes the following commits:

d047502 [Nezih Yigitbasi] Add unit test
e4cd545 [Nezih Yigitbasi] Get rid of deprecated methods
bdc8fdf [Nezih Yigitbasi] Handle all map key types with cat tool's json dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants