diff --git a/cpp/examples/arrow/acero_register_example.cc b/cpp/examples/arrow/acero_register_example.cc index f6c73b08a721..4975f1424841 100644 --- a/cpp/examples/arrow/acero_register_example.cc +++ b/cpp/examples/arrow/acero_register_example.cc @@ -137,7 +137,8 @@ arrow::Status RunComputeRegister(int argc, char** argv) { // FunctionOptions for which serialization is not supported. auto expr = cp::call(name, {}, options); auto maybe_serialized = cp::Serialize(expr); - std::cerr << maybe_serialized.status().ToString() << std::endl; + std::cout << "Serializing an expression with ExampleFunctionOptions fails as expected: " + << maybe_serialized.status().ToString() << std::endl; auto exec_registry = ac::default_exec_factory_registry(); ARROW_RETURN_NOT_OK( diff --git a/cpp/src/arrow/compute/expression_test.cc b/cpp/src/arrow/compute/expression_test.cc index 10c1b348e62d..248489874ea3 100644 --- a/cpp/src/arrow/compute/expression_test.cc +++ b/cpp/src/arrow/compute/expression_test.cc @@ -2247,6 +2247,15 @@ TEST(Expression, Filter) { ])"); } +TEST(Expression, SerializeCustomOptions) { + // GH-30923: custom FunctionOptionsType cannot be serialized + auto expr = call("widgetify", {}, std::make_shared()); + EXPECT_RAISES_WITH_MESSAGE_THAT( + NotImplemented, + HasSubstr("FunctionOptions type 'widgetify' is not supported: only built-in"), + Serialize(expr)); +} + TEST(Expression, SerializationRoundTrips) { auto ExpectRoundTrips = [](const Expression& expr) { ASSERT_OK_AND_ASSIGN(auto serialized, Serialize(expr)); diff --git a/cpp/src/arrow/compute/function_internal.cc b/cpp/src/arrow/compute/function_internal.cc index 8d85254209d7..bbe0d7f95ef0 100644 --- a/cpp/src/arrow/compute/function_internal.cc +++ b/cpp/src/arrow/compute/function_internal.cc @@ -45,8 +45,10 @@ Result> FunctionOptionsToStructScalar( const auto* options_type = dynamic_cast(options.options_type()); if (!options_type) { - return Status::NotImplemented("serializing ", options.type_name(), - " to StructScalar"); + return Status::NotImplemented("Serialization of FunctionOptions type '", + options.type_name(), + "' is not supported: only built-in options types " + "can be serialized"); } RETURN_NOT_OK(options_type->ToStructScalar(options, &field_names, &values)); field_names.push_back(kTypeNameField);