Skip to content

GH-51013: [C++] Replace RapidJSON in JSON test utilities - #51014

Open
Reranko05 wants to merge 5 commits into
apache:mainfrom
Reranko05:gh-35460-tests
Open

GH-51013: [C++] Replace RapidJSON in JSON test utilities#51014
Reranko05 wants to merge 5 commits into
apache:mainfrom
Reranko05:gh-35460-tests

Conversation

@Reranko05

@Reranko05 Reranko05 commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Rationale for this change

This PR continues the simdjson migration by replacing RapidJSON usage in the C++ JSON test and testing utilities with simdjson and Arrow's existing JsonWriter.

Changes

  • Replace rapidjson::Writer and StringBuffer usage in JSON test utilities with JsonWriter.
  • Replace RapidJSON-based JSON pretty-printing with simdjson-based parsing and serialization.
  • Use JsonWriter to correctly escape JSON object keys during pretty-printing.
  • Replace RapidJSON DOM parsing in TensorFromJSON() with simdjson's DOM API.
  • Add regression coverage for escaped JSON object keys in PrettyPrint().
  • Add test coverage for TensorFromJSON() with strides and dimension names.
  • Update test linking to include arrow::simdjson.

@Reranko05 Reranko05 added the CI: Extra: C++ Run extra C++ CI label Aug 26, 2026
@Reranko05
Reranko05 marked this pull request as ready for review August 27, 2026 12:19
@Reranko05
Reranko05 requested a review from pitrou as a code owner August 27, 2026 12:19
Copilot AI lite review requested due to automatic review settings August 27, 2026 12:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Reranko05
Reranko05 requested review from kou and rok August 27, 2026 12:20
return Status::Invalid("Unreachable");
}

inline Status PrettyPrintJsonValue(simdjson::ondemand::value value, std::string* out,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we please move this to simdjson_internal.cc? There's no reason to inline the implement in the .h file.

Also, can this return Result<std::string>? It would be more idiomatic than an out-pointer parameter.


#include <simdjson.h>

#include "arrow/json/json_writer_internal.h"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't be including arrow/json IMHO. Let's wait for #50990 to be merged perhaps?

rj::PrettyWriter<rj::StringBuffer> writer(sb);
document.Accept(writer);
return sb.GetString();
simdjson::padded_string json(one_line.data(), one_line.size());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not use fractured_json_string?

Comment on lines +557 to +560
auto json_result = writer.GetString();
ABORT_NOT_OK(json_result.status());
auto json_view = std::move(json_result).ValueOrDie();
std::string json(json_view);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you can write this more concisely as:

Suggested change
auto json_result = writer.GetString();
ABORT_NOT_OK(json_result.status());
auto json_view = std::move(json_result).ValueOrDie();
std::string json(json_view);
std::string json = writer.GetString().As<std::string>();

R"([{"c":true, "d": "1991-02-03"}, {"c":false, "d":"2019-04-01"}])"});
}

TEST(JsonTest, PrettyPrintEscapesObjectKeys) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't seem like a great place for this test but I can't think of anything better.

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting committer review Awaiting committer review CI: Extra: C++ Run extra C++ CI Component: C++

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants