Skip to content

Commit 2059243

Browse files
authored
GH-47243: [C++] Initialize arrow::compute in execution_plan_documentation_examples (#47227)
### Rationale for this change fix example running error ``` ****** Scan Example ****** Error occurred: No function registered with name: make_struct ``` ### What changes are included in this PR? call arrow::compute::initialize ahead ### Are these changes tested? yes ### Are there any user-facing changes? no * GitHub Issue: #47243 Lead-authored-by: egolearner <[email protected]> Co-authored-by: egolearner <[email protected]> Signed-off-by: Raúl Cumplido <[email protected]>
1 parent 697f501 commit 2059243

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

cpp/examples/arrow/dataset_documentation_example.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// intended to be paired with the documentation.
2020

2121
#include <arrow/api.h>
22+
#include <arrow/compute/api.h>
2223
#include <arrow/compute/cast.h>
2324
#include <arrow/dataset/dataset.h>
2425
#include <arrow/dataset/discovery.h>
@@ -326,6 +327,8 @@ arrow::Result<std::shared_ptr<arrow::Table>> FilterPartitionedDataset(
326327

327328
arrow::Status RunDatasetDocumentation(const std::string& format_name,
328329
const std::string& uri, const std::string& mode) {
330+
ARROW_RETURN_NOT_OK(arrow::compute::Initialize());
331+
329332
std::string base_path;
330333
std::shared_ptr<ds::FileFormat> format;
331334
std::string root_path;

cpp/examples/arrow/execution_plan_documentation_examples.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -825,14 +825,13 @@ enum ExampleMode {
825825
};
826826

827827
int main(int argc, char** argv) {
828-
if (argc < 3) {
829-
// Fake success for CI purposes.
830-
return EXIT_SUCCESS;
828+
int mode = argc > 1 ? std::atoi(argv[2]) : SOURCE_SINK;
829+
std::string base_save_path = argc > 2 ? argv[2] : "";
830+
arrow::Status status = arrow::compute::Initialize();
831+
if (!status.ok()) {
832+
std::cout << "Error occurred: " << status.message() << std::endl;
833+
return EXIT_FAILURE;
831834
}
832-
833-
std::string base_save_path = argv[1];
834-
int mode = std::atoi(argv[2]);
835-
arrow::Status status;
836835
// ensure arrow::dataset node factories are in the registry
837836
arrow::dataset::internal::Initialize();
838837
switch (mode) {

0 commit comments

Comments
 (0)