cql3/functions/user_function: Print arguments and return type without frozen

Scylla doesn't allow for the types of arguments or the return type
to be frozen. As a result, before these changes, create statements
produced to restore UDFs as part of `DESCRIBE` statements could not
be executed.

We fix that and add a reproducer test and another one to verify that
the implementation is correct.

(cherry picked from commit 8582ed513b)

# Conflicts:
#	cql3/functions/user_function.cc
#	test/cql-pytest/test_describe.py
This commit is contained in:
Dawid Mędrek
2024-09-25 14:47:10 +02:00
committed by Mergify
parent ab2d7278e0
commit 7f01cd7dc0
2 changed files with 1401 additions and 1 deletions

View File

@@ -72,6 +72,7 @@ std::ostream& user_function::describe(std::ostream& os) const {
auto ks = cql3::util::maybe_quote(name().keyspace);
auto na = cql3::util::maybe_quote(name().name);
<<<<<<< HEAD
os << "CREATE FUNCTION " << ks << "." << na << "(";
for (size_t i = 0; i < _arg_names.size(); i++) {
if (i > 0) {
@@ -97,6 +98,9 @@ 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_type_range = _arg_types | std::views::transform(std::mem_fn(&abstract_type::cql3_type_name_without_frozen));
>>>>>>> 8582ed513b (cql3/functions/user_function: Print arguments and return type without frozen)
auto arg_range = std::views::zip(_arg_names, arg_type_range)
| std::views::transform([] (std::tuple<std::string_view, std::string_view> arg) {
const auto [name, type] = arg;
@@ -110,7 +114,7 @@ std::ostream& user_function::describe(std::ostream& os) const {
"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(),
_return_type->cql3_type_name_without_frozen(),
_language,
_body);
});

File diff suppressed because it is too large Load Diff