diff --git a/cql3/functions/user_function.cc b/cql3/functions/user_function.cc index 2bae075ff6..eeb24590d3 100644 --- a/cql3/functions/user_function.cc +++ b/cql3/functions/user_function.cc @@ -13,6 +13,8 @@ #include +#include + namespace cql3 { namespace functions { @@ -79,6 +81,7 @@ std::ostream& user_function::describe(std::ostream& os) const { } os << ")\n"; +<<<<<<< HEAD if (_called_on_null_input) { os << "CALLED"; } else { @@ -92,6 +95,33 @@ std::ostream& user_function::describe(std::ostream& os) const { << "$$;"; return os; +======= + auto arg_type_range = _arg_types | std::views::transform(std::mem_fn(&abstract_type::cql3_type_name)); + auto arg_range = std::views::zip(_arg_names, arg_type_range) + | std::views::transform([] (std::tuple arg) { + const auto [name, type] = arg; + return seastar::format("{} {}", name, type); + }); + + return seastar::format("CREATE FUNCTION {}.{}({})\n" + "{} ON NULL INPUT\n" + "RETURNS {}\n" + "LANGUAGE {}\n" + "AS $${}$$;", + cql3::util::maybe_quote(name().keyspace), cql3::util::maybe_quote(name().name), fmt::join(arg_range, ", "), + _called_on_null_input ? "CALLED" : "RETURNS NULL", + _return_type->cql3_type_name(), + _language, + _body); + }); + + return description { + .keyspace = name().keyspace, + .type = "function", + .name = name().name, + .create_statement = std::move(maybe_create_statement) + }; +>>>>>>> 1f1b201fd8 (cql3/functions/user_function: Use fmt to format create statement) } }