Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRILL-5033: Query on JSON That Has Null as Value For Each Key #2731

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,8 @@ private void writeData(MapWriter map, FieldSelection selection,
break;

case VALUE_NULL:
// do nothing as we don't have a type.
// handle a null value as a string
handleString(parser, map, fieldName);
break;

case VALUE_NUMBER_FLOAT:
Expand Down Expand Up @@ -413,6 +414,10 @@ private boolean writeListDataIfTyped(ListWriter writer) throws IOException {

private void handleString(JsonParser parser, MapWriter writer, String fieldName) throws IOException {
try {
if (parser.nextToken() == VALUE_NULL)
writer.varChar(fieldName)
.writeVarChar(0, workingBuffer.prepareVarCharHolder("null"), workingBuffer.getBuf());
else
writer.varChar(fieldName)
.writeVarChar(0, workingBuffer.prepareVarCharHolder(parser.getText()), workingBuffer.getBuf());
} catch (IllegalArgumentException e) {
Expand Down