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

Fix field name matching in get_json_object with escaped characters #2410

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/cpp/src/json_parser.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ class json_parser {

if (!to_match.is_null()) {
for (cudf::size_type i = 0; i < bytes; i++) {
if (!(to_match.eof() && to_match.current_char() == buff[i])) { return false; }
if (to_match.eof() || to_match.current_char() != buff[i]) { return false; }
to_match.next();
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/com/nvidia/spark/rapids/jni/GetJsonObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,18 @@ void getJsonObjectTest_ExceedMaxNestingDepthInJSONParser() {
}
}

@Test
void getJsonObjectTest_NamesWithEscapedCharacters() {
JSONUtils.PathInstructionJni[] query = new JSONUtils.PathInstructionJni[] {
namedPath("data")
};
try (ColumnVector input = ColumnVector.fromStrings(
"{'data': 'TEST1'}", "{'\\u0064\\u0061t\\u0061': 'TEST2'}");
ColumnVector expected = ColumnVector.fromStrings("TEST1", "TEST2");
ColumnVector output = JSONUtils.getJsonObject(input, query)) {
assertColumnsAreEqual(expected, output);
}
}

private JSONUtils.PathInstructionJni wildcardPath() {
return new JSONUtils.PathInstructionJni(JSONUtils.PathInstructionType.WILDCARD, "", -1);
Expand Down
Loading