| 441 | } |
| 442 | |
| 443 | Result<std::string> SubstraitToJSON(std::string_view type_name, const Buffer& buf) { |
| 444 | std::string type_url = "/substrait." + std::string(type_name); |
| 445 | |
| 446 | google::protobuf::io::ArrayInputStream buf_stream{buf.data(), |
| 447 | static_cast<int>(buf.size())}; |
| 448 | |
| 449 | std::string out; |
| 450 | google::protobuf::io::StringOutputStream out_stream{&out}; |
| 451 | |
| 452 | auto status = google::protobuf::util::BinaryToJsonStream( |
| 453 | GetGeneratedTypeResolver(), type_url, &buf_stream, &out_stream); |
| 454 | if (!status.ok()) { |
| 455 | return Status::Invalid("BinaryToJsonStream returned ", status); |
| 456 | } |
| 457 | return out; |
| 458 | } |
| 459 | |
| 460 | } // namespace internal |
| 461 | } // namespace engine |
no test coverage detected