Skip to content

Commit ada8750

Browse files
authored
GH-44563: [C++] FunctionOptions::{Serialize,Deserialize}() return an error without ARROW_IPC (#45171)
### Rationale for this change They use IPC format internally. So we can't do them without `ARROW_IPC`. ### What changes are included in this PR? Returns `arrow::Status::NotImplemented` without `ARROW_IPC`. ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes. * GitHub Issue: #44563 Authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
1 parent 1938582 commit ada8750

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

cpp/src/arrow/compute/function_internal.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18+
#include "arrow/util/config.h"
19+
1820
#include "arrow/compute/function_internal.h"
1921

2022
#include "arrow/array/util.h"
2123
#include "arrow/compute/function.h"
2224
#include "arrow/compute/registry.h"
2325
#include "arrow/io/memory.h"
24-
#include "arrow/ipc/reader.h"
25-
#include "arrow/ipc/writer.h"
26+
#ifdef ARROW_IPC
27+
# include "arrow/ipc/reader.h"
28+
# include "arrow/ipc/writer.h"
29+
#endif
2630
#include "arrow/record_batch.h"
2731
#include "arrow/scalar.h"
2832
#include "arrow/util/checked_cast.h"
@@ -65,6 +69,7 @@ Result<std::unique_ptr<FunctionOptions>> FunctionOptionsFromStructScalar(
6569

6670
Result<std::shared_ptr<Buffer>> GenericOptionsType::Serialize(
6771
const FunctionOptions& options) const {
72+
#ifdef ARROW_IPC
6873
ARROW_ASSIGN_OR_RAISE(auto scalar, FunctionOptionsToStructScalar(options));
6974
ARROW_ASSIGN_OR_RAISE(auto array, MakeArrayFromScalar(*scalar, 1));
7075
auto batch =
@@ -74,6 +79,9 @@ Result<std::shared_ptr<Buffer>> GenericOptionsType::Serialize(
7479
RETURN_NOT_OK(writer->WriteRecordBatch(*batch));
7580
RETURN_NOT_OK(writer->Close());
7681
return stream->Finish();
82+
#else
83+
return Status::NotImplemented("IPC feature isn't enabled");
84+
#endif
7785
}
7886

7987
Result<std::unique_ptr<FunctionOptions>> GenericOptionsType::Deserialize(
@@ -83,6 +91,7 @@ Result<std::unique_ptr<FunctionOptions>> GenericOptionsType::Deserialize(
8391

8492
Result<std::unique_ptr<FunctionOptions>> DeserializeFunctionOptions(
8593
const Buffer& buffer) {
94+
#ifdef ARROW_IPC
8695
// Copying the buffer here is not ideal, but we need to do it to avoid
8796
// use-after-free issues with the zero-copy buffer read.
8897
auto stream = io::BufferReader::FromString(buffer.ToString());
@@ -108,6 +117,9 @@ Result<std::unique_ptr<FunctionOptions>> DeserializeFunctionOptions(
108117
checked_cast<const StructArray&>(*column).GetScalar(0));
109118
auto scalar = checked_cast<const StructScalar&>(*raw_scalar);
110119
return FunctionOptionsFromStructScalar(scalar);
120+
#else
121+
return Status::NotImplemented("IPC feature isn't enabled");
122+
#endif
111123
}
112124

113125
Status CheckAllArrayOrScalar(const std::vector<Datum>& values) {

0 commit comments

Comments
 (0)