diff --git a/mutation_partition.cc b/mutation_partition.cc index b189528103..771a72617a 100644 --- a/mutation_partition.cc +++ b/mutation_partition.cc @@ -596,7 +596,7 @@ static void get_compacted_row_slice(const schema& s, } else { auto&& mut = cell->as_collection_mutation(); auto&& ctype = static_pointer_cast(def.type); - if (ctype->is_empty(mut)) { + if (!ctype->is_any_live(mut)) { writer.add().skip(); } else { write_cell(writer, slice, def.type, mut); diff --git a/tests/cql_query_test.cc b/tests/cql_query_test.cc index 3b2f2be6b9..93e7a82268 100644 --- a/tests/cql_query_test.cc +++ b/tests/cql_query_test.cc @@ -2103,6 +2103,24 @@ SEASTAR_TEST_CASE(test_alter_table) { }); }); } + +SEASTAR_TEST_CASE(test_map_query) { + return do_with_cql_env([] (auto& e) { + return seastar::async([&e] { + e.execute_cql("CREATE TABLE xx (k int PRIMARY KEY, m map);").get(); + e.execute_cql("insert into xx (k, m) values (0, {'v2': 1});").get(); + auto m_type = map_type_impl::get_instance(utf8_type, int32_type, true); + assert_that(e.execute_cql("select m from xx where k = 0;").get0()) + .is_rows().with_rows({ + { make_map_value(m_type, map_type_impl::native_type({{sstring("v2"), 1}})).serialize() } + }); + e.execute_cql("delete m['v2'] from xx where k = 0;").get(); + assert_that(e.execute_cql("select m from xx where k = 0;").get0()) + .is_rows().with_rows({{{}}}); + }); + }); +} + SEASTAR_TEST_CASE(test_drop_table) { return do_with_cql_env([] (auto& e) { return seastar::async([&e] { diff --git a/types.hh b/types.hh index ecaece4082..ef657c8e17 100644 --- a/types.hh +++ b/types.hh @@ -723,7 +723,7 @@ public: static bytes pack(BytesViewIterator start, BytesViewIterator finish, int elements, cql_serialization_format sf); static mutation_view deserialize_mutation_form(collection_mutation_view in); bool is_empty(collection_mutation_view in) const; - bool is_any_live(collection_mutation_view in, tombstone tomb, gc_clock::time_point now) const; + bool is_any_live(collection_mutation_view in, tombstone tomb = tombstone(), gc_clock::time_point now = gc_clock::time_point::min()) const; virtual bytes to_value(mutation_view mut, cql_serialization_format sf) const = 0; bytes to_value(collection_mutation_view mut, cql_serialization_format sf) const; // FIXME: use iterators?