From aa476cd6c99e34dfcaef2eaee25a0b69fceb91ae Mon Sep 17 00:00:00 2001 From: Duarte Nunes Date: Sun, 27 Jan 2019 22:24:04 +0000 Subject: [PATCH] index/secondary_index_manager: Add virtual columns to MV Virtual columns are MV-specific columns that contribute to the liveness of view rows. However, we were not adding those columns when creating an index's underlying MV, causing indexes to miss base rows. Fixes #4144 Branches: master, branch-3.0 Signed-off-by: Duarte Nunes --- index/secondary_index_manager.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index/secondary_index_manager.cc b/index/secondary_index_manager.cc index 1024483ba5..99281689b8 100644 --- a/index/secondary_index_manager.cc +++ b/index/secondary_index_manager.cc @@ -134,6 +134,11 @@ view_ptr secondary_index_manager::create_view_for_index(const index_metadata& im } builder.with_column(col.name(), col.type, column_kind::clustering_key); } + if (index_target->is_primary_key()) { + for (auto& def : schema->regular_columns()) { + db::view::create_virtual_column(builder, def.name(), def.type); + } + } const sstring where_clause = format("{} IS NOT NULL", cql3::util::maybe_quote(index_target_name)); builder.with_view_info(*schema, false, where_clause); return view_ptr{builder.build()};