-
Notifications
You must be signed in to change notification settings - Fork 4k
GH-45908: [C++][Docs] Rename and expose basic {Array,...}FromJSON helpers as public APIs #46180
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
Merged
amoeba
merged 33 commits into
apache:main
from
amoeba:feature/GH-45908--expose-from-json
May 14, 2025
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
e6b8267
Move core *FromJSON helpers from ipc to util NS
amoeba cf808f9
Add docs for FromJSON helpers
amoeba 644d407
Update meson.build
amoeba 6fbb2f3
Fix path in meson.build
amoeba ce373f5
Remove JSON bits from IPC
amoeba 6479400
Use using in hash_join_node_test.cc
amoeba 974afd1
Update hash_join_node_test.cc
amoeba 8b38e85
Improve API docs section
amoeba f3d37dc
Point JSON link to RFC 8259
amoeba 09c6e82
Prefer using in bridge_test.cc
amoeba 0a342e3
Update cpp/src/arrow/util/from_json_test.cc
amoeba 3254825
Remove from_json.h from api.h
amoeba b4a9ef4
Add `class` keyword back in to disambiguate
amoeba 2691fe7
Minor edits to user guide code sample
amoeba 3c06d36
Update cpp/src/arrow/util/from_json.h
amoeba 1bb08eb
Update user guide docs per review comment
amoeba 11da4d4
Use explicit namespace on StringBuilder
amoeba 28e2c33
Rename util::*FromJSON to json::*FromJSONString
amoeba b1f984c
Update generate_fuzz_corpus.cc
amoeba 24e757b
Move anonymous part of from_string.cc into an internal name namespace
amoeba 38a944a
Remove from_string from ipc/api.h
amoeba a585a13
Update gdb.cc
amoeba 22555c8
Update extensions.pyx
amoeba a965af5
Sync docs changes with code changes
amoeba 21d485b
whoops
amoeba fb02952
run clang-format on c++ example code
amoeba be2cbc1
Update docs/source/cpp/arrays.rst
amoeba 4a9bc3e
Update docs/source/cpp/api/array.rst
amoeba 279f5ab
Update cpp/src/arrow/json/from_string.h
amoeba 5cedcfe
Fixes/improvements for docs
amoeba b5ed9b1
testing theory on ci failure
amoeba 96ed729
Revert "testing theory on ci failure"
amoeba f91dd1c
Update cpp/examples/arrow/from_json_string_example.cc
amoeba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| // This example shows how to use some of the *FromJSONString helpers. | ||
|
|
||
| #include <iostream> | ||
| #include <memory> | ||
|
|
||
| #include <arrow/api.h> | ||
| #include <arrow/array/array_base.h> | ||
| #include <arrow/json/from_string.h> | ||
| #include <arrow/status.h> | ||
|
|
||
| using arrow::json::ArrayFromJSONString; | ||
| using arrow::json::ChunkedArrayFromJSONString; | ||
| using arrow::json::DictArrayFromJSONString; | ||
|
|
||
| /** | ||
| * \brief Run Example | ||
| * | ||
| * ./debug/from-json-string-example | ||
| */ | ||
| arrow::Status RunExample() { | ||
| // Simple types | ||
| ARROW_ASSIGN_OR_RAISE(auto int32_array, | ||
| ArrayFromJSONString(arrow::int32(), "[1, 2, 3]")); | ||
| ARROW_ASSIGN_OR_RAISE(auto float64_array, | ||
| ArrayFromJSONString(arrow::float64(), "[4.0, 5.0, 6.0]")); | ||
| ARROW_ASSIGN_OR_RAISE(auto bool_array, | ||
| ArrayFromJSONString(arrow::boolean(), "[true, false, true]")); | ||
| ARROW_ASSIGN_OR_RAISE( | ||
| auto string_array, | ||
| ArrayFromJSONString(arrow::utf8(), R"(["Hello", "World", null])")); | ||
|
|
||
| // Timestamps can be created from string representations | ||
| ARROW_ASSIGN_OR_RAISE( | ||
| auto ts_array, | ||
| ArrayFromJSONString(timestamp(arrow::TimeUnit::SECOND), | ||
| R"(["1970-01-01", "2000-02-29","3989-07-14","1900-02-28"])")); | ||
|
|
||
| // List, Map, Struct | ||
| ARROW_ASSIGN_OR_RAISE( | ||
| auto list_array, | ||
| ArrayFromJSONString(list(arrow::int64()), | ||
| "[[null], [], null, [4, 5, 6, 7, 8], [2, 3]]")); | ||
| ARROW_ASSIGN_OR_RAISE( | ||
| auto map_array, | ||
| ArrayFromJSONString(map(arrow::utf8(), arrow::int32()), | ||
| R"([[["joe", 0], ["mark", null]], null, [["cap", 8]], []])")); | ||
| ARROW_ASSIGN_OR_RAISE( | ||
| auto struct_array, | ||
| ArrayFromJSONString( | ||
| arrow::struct_({field("one", arrow::int32()), field("two", arrow::int32())}), | ||
| "[[11, 22], null, [null, 33]]")); | ||
|
|
||
| // ChunkedArrayFromJSONString | ||
| std::shared_ptr<arrow::ChunkedArray> chunked_array; | ||
| ARROW_RETURN_NOT_OK(ChunkedArrayFromJSONString( | ||
| arrow::int32(), {"[5, 10]", "[null]", "[16]"}, &chunked_array)); | ||
|
|
||
| // DictArrayFromJSONString | ||
| std::shared_ptr<arrow::Array> dict_array; | ||
| ARROW_RETURN_NOT_OK(DictArrayFromJSONString( | ||
| dictionary(arrow::int32(), arrow::utf8()), "[0, 1, 0, 2, 0, 3]", | ||
| R"(["k1", "k2", "k3", "k4"])", &dict_array)); | ||
|
|
||
| return arrow::Status::OK(); | ||
| } | ||
|
|
||
| int main(int argc, char** argv) { | ||
| auto status = RunExample(); | ||
| if (!status.ok()) { | ||
| std::cerr << status.ToString() << std::endl; | ||
| return EXIT_FAILURE; | ||
| } | ||
| return EXIT_SUCCESS; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.