This is an automated email from the ASF dual-hosted git repository.
raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 2059243970 GH-47243: [C++] Initialize arrow::compute in
execution_plan_documentation_examples (#47227)
2059243970 is described below
commit 205924397034f7bd4ecc06660a9adf0c37604ce8
Author: egolearner <[email protected]>
AuthorDate: Wed Aug 27 16:13:02 2025 +0800
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]>
---
cpp/examples/arrow/dataset_documentation_example.cc | 3 +++
cpp/examples/arrow/execution_plan_documentation_examples.cc | 13 ++++++-------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/cpp/examples/arrow/dataset_documentation_example.cc
b/cpp/examples/arrow/dataset_documentation_example.cc
index c78f6d5984..3320918c62 100644
--- a/cpp/examples/arrow/dataset_documentation_example.cc
+++ b/cpp/examples/arrow/dataset_documentation_example.cc
@@ -19,6 +19,7 @@
// intended to be paired with the documentation.
#include <arrow/api.h>
+#include <arrow/compute/api.h>
#include <arrow/compute/cast.h>
#include <arrow/dataset/dataset.h>
#include <arrow/dataset/discovery.h>
@@ -326,6 +327,8 @@ arrow::Result<std::shared_ptr<arrow::Table>>
FilterPartitionedDataset(
arrow::Status RunDatasetDocumentation(const std::string& format_name,
const std::string& uri, const
std::string& mode) {
+ ARROW_RETURN_NOT_OK(arrow::compute::Initialize());
+
std::string base_path;
std::shared_ptr<ds::FileFormat> format;
std::string root_path;
diff --git a/cpp/examples/arrow/execution_plan_documentation_examples.cc
b/cpp/examples/arrow/execution_plan_documentation_examples.cc
index b92f5801c1..a8d50b22e6 100644
--- a/cpp/examples/arrow/execution_plan_documentation_examples.cc
+++ b/cpp/examples/arrow/execution_plan_documentation_examples.cc
@@ -825,14 +825,13 @@ enum ExampleMode {
};
int main(int argc, char** argv) {
- if (argc < 3) {
- // Fake success for CI purposes.
- return EXIT_SUCCESS;
+ int mode = argc > 1 ? std::atoi(argv[2]) : SOURCE_SINK;
+ std::string base_save_path = argc > 2 ? argv[2] : "";
+ arrow::Status status = arrow::compute::Initialize();
+ if (!status.ok()) {
+ std::cout << "Error occurred: " << status.message() << std::endl;
+ return EXIT_FAILURE;
}
-
- std::string base_save_path = argv[1];
- int mode = std::atoi(argv[2]);
- arrow::Status status;
// ensure arrow::dataset node factories are in the registry
arrow::dataset::internal::Initialize();
switch (mode) {