From be1490441622539aaafc3fec3166091dcbfb1d08 Mon Sep 17 00:00:00 2001 From: Jan Ciolek Date: Fri, 3 Dec 2021 14:33:41 +0100 Subject: [PATCH 1/2] cql3: Don't allow unset values inside UDT Scylla doesn't support unset values inside UDT. The old code used to convert unset to null, which seems incorrect. There is an extra space in the error message to retain compatability with Cassandra. Signed-off-by: Jan Ciolek --- cql3/expr/expression.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cql3/expr/expression.cc b/cql3/expr/expression.cc index 36074c5a0d..1ef1986b3f 100644 --- a/cql3/expr/expression.cc +++ b/cql3/expr/expression.cc @@ -1679,8 +1679,8 @@ constant evaluate(const usertype_constructor& user_val, const query_options& opt constant field_val = evaluate(cur_field->second, options); if (field_val.is_unset_value()) { - // TODO: Behaviour copied from user_types::delayed_value::bind(), but this seems incorrect - field_val.value = raw_value::make_null(); + throw exceptions::invalid_request_exception(format( + "Invalid unset value for field '{}' of user defined type ", utype.field_name_as_string(i))); } field_values.emplace_back(std::move(field_val.value).to_managed_bytes_opt()); From 3ae87528120227568d1e114513a5c50086c1f9d1 Mon Sep 17 00:00:00 2001 From: Jan Ciolek Date: Fri, 3 Dec 2021 14:02:26 +0100 Subject: [PATCH 2/2] cql-pytest: Enable test for UDT with unset values The test testUDTWithUnsetValues was marked as xfail, but now the issue has been fixed and we can enable it. Signed-off-by: Jan Ciolek --- .../cassandra_tests/validation/entities/user_types_test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cql-pytest/cassandra_tests/validation/entities/user_types_test.py b/test/cql-pytest/cassandra_tests/validation/entities/user_types_test.py index 79bcd2c0c5..a5d470b812 100644 --- a/test/cql-pytest/cassandra_tests/validation/entities/user_types_test.py +++ b/test/cql-pytest/cassandra_tests/validation/entities/user_types_test.py @@ -169,7 +169,6 @@ def testAlterNonFrozenUDT(cql, test_keyspace): assert_rows(execute(cql, table, "SELECT v FROM %s"), [user_type("a", 3, "foo", "abc", "c", 0)]) assert_rows(execute(cql, table, "SELECT v.c FROM %s"), [0]) -@pytest.mark.xfail(reason="#9671") def testUDTWithUnsetValues(cql, test_keyspace): with create_type(cql, test_keyspace, "(x int, y int)") as myType: with create_type(cql, test_keyspace, f"(a frozen<{myType}>)") as myOtherType: