diff --git a/test/cqlpy/test_tools.py b/test/cqlpy/test_tools.py index eea4f4ab55..f6188446cb 100644 --- a/test/cqlpy/test_tools.py +++ b/test/cqlpy/test_tools.py @@ -1826,11 +1826,26 @@ textwrap.dedent(""" None, ) +scylla_sstable_query_nested_udt = scylla_sstable_query_simple_table_param( +textwrap.dedent(""" + CREATE TABLE {}.{} ( + pk int PRIMARY KEY, + col_nested_udt list> + ) WITH + compaction = {{'class': 'NullCompactionStrategy'}}; +"""), + "INSERT INTO {}.{} (pk, col_nested_udt) VALUES (?, ?)", + (0, [my_udt(10, 'aasdad')]), + "CREATE TYPE {}.my_type (field_1 int, field_2 text)", + "DROP TYPE {}.my_type", +) + @pytest.mark.parametrize("test_keyspace", ["tablets", "vnodes"], indirect=True) @pytest.mark.parametrize("test_table", [ scylla_sstable_query_simple_all_types_param, scylla_sstable_query_simple_collection_types_param, scylla_sstable_query_simple_counter_param, + scylla_sstable_query_nested_udt, ]) def test_scylla_sstable_query_data_types(request, cql, test_keyspace, test_table, scylla_path, scylla_data_dir, temp_workdir): """Check read-all queries with all data-types. diff --git a/tools/scylla-sstable.cc b/tools/scylla-sstable.cc index 4a3eacf2aa..f6a92acdb0 100644 --- a/tools/scylla-sstable.cc +++ b/tools/scylla-sstable.cc @@ -1651,9 +1651,9 @@ future create_table_in_cql_env(cql_test_env& env, schema_ptr ss builder.with_column(col.name(), col.type, col_kind, col.view_virtual()); // Register any user types, so they are known by the time we create the table. - if (col.type->is_user_type()) { - keyspace.add_user_type(dynamic_pointer_cast(col.type)); - } + invoke_on_user_type(col.type, [&keyspace] (const user_type_impl& udt) { + keyspace.add_user_type(dynamic_pointer_cast(udt.shared_from_this())); + }); } } auto schema = builder.build();