diff --git a/cql3/selection/selectable.cc b/cql3/selection/selectable.cc index 8a95e2e874..9db1d12102 100644 --- a/cql3/selection/selectable.cc +++ b/cql3/selection/selectable.cc @@ -142,7 +142,7 @@ shared_ptr selectable::with_field_selection::new_selector_factory(database& db, schema_ptr s, std::vector& defs) { auto&& factory = _selected->new_selector_factory(db, s, defs); auto&& type = factory->new_instance()->get_type(); - auto&& ut = dynamic_pointer_cast(std::move(type)); + auto&& ut = dynamic_pointer_cast(type->underlying_type()); if (!ut) { throw exceptions::invalid_request_exception( format("Invalid field selection: {} of type {} is not a user type", diff --git a/cql3/tuples.cc b/cql3/tuples.cc index d9af5044f7..10cd6a25bd 100644 --- a/cql3/tuples.cc +++ b/cql3/tuples.cc @@ -32,7 +32,7 @@ tuples::component_spec_of(shared_ptr column, size_t compon column->ks_name, column->cf_name, ::make_shared(format("{}[{:d}]", column->name, component), true), - static_pointer_cast(column->type)->type(component)); + static_pointer_cast(column->type->underlying_type())->type(component)); } shared_ptr diff --git a/cql3/tuples.hh b/cql3/tuples.hh index 7402b85b14..9d3fdeb5af 100644 --- a/cql3/tuples.hh +++ b/cql3/tuples.hh @@ -70,7 +70,7 @@ public: private: void validate_assignable_to(database& db, const sstring& keyspace, shared_ptr receiver) { - auto tt = dynamic_pointer_cast(receiver->type); + auto tt = dynamic_pointer_cast(receiver->type->underlying_type()); if (!tt) { throw exceptions::invalid_request_exception(format("Invalid tuple type literal for {} of type {}", receiver->name, receiver->type->as_cql3_type())); } diff --git a/tests/cql_query_test.cc b/tests/cql_query_test.cc index a785e76e27..842d464165 100644 --- a/tests/cql_query_test.cc +++ b/tests/cql_query_test.cc @@ -1544,6 +1544,18 @@ SEASTAR_TEST_CASE(test_user_type_nested) { }); } +SEASTAR_TEST_CASE(test_user_type_reversed) { + return do_with_cql_env_thread([](cql_test_env& e) { + e.execute_cql("create type my_type (a int);").get(); + e.execute_cql("create table tbl (a int, b frozen, primary key ((a), b)) with clustering order by (b desc);").get(); + e.execute_cql("insert into tbl (a, b) values (1, (2));").get(); + assert_that(e.execute_cql("select a,b.a from tbl;").get0()) + .is_rows() + .with_size(1) + .with_row({int32_type->decompose(1), int32_type->decompose(2)}); + }); +} + SEASTAR_TEST_CASE(test_user_type) { return do_with_cql_env([] (cql_test_env& e) { return e.execute_cql("create type ut1 (my_int int, my_bigint bigint, my_text text);").discard_result().then([&e] {