From 138c68d80e3a5cd7e73bd10a9bb51e0cf00a030d Mon Sep 17 00:00:00 2001 From: Wojciech Mitros Date: Mon, 2 Dec 2024 22:16:55 +0100 Subject: [PATCH] mv: forbid views with tablets by default Materialized views with tablets are not stable yet, but we want them available as an experimental feature, mainly for teseting. The feature was added in scylladb/scylladb#21833, but currently it has no effect. All tests have been updated to use the feature, so we should finally make it work. This patch prevents users from creating materialized views in keyspaces using tablets when the VIEWS_WITH_TABLETS feature is not enabled - such requests will now get rejected. Fixes scylladb/scylladb#21832 Closes scylladb/scylladb#22217 (cherry picked from commit 677f9962cf4e2b0aff2bb81f7b000f4adb5f2166) Closes scylladb/scylladb#22659 --- cql3/statements/create_index_statement.cc | 3 +++ cql3/statements/create_view_statement.cc | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cql3/statements/create_index_statement.cc b/cql3/statements/create_index_statement.cc index 8167faaefc..3110b554f3 100644 --- a/cql3/statements/create_index_statement.cc +++ b/cql3/statements/create_index_statement.cc @@ -87,6 +87,9 @@ std::vector<::shared_ptr> create_index_statement::validate_while_e "Secondary indexes are not supported on COMPACT STORAGE tables that have clustering columns"); } + if (!db.features().views_with_tablets && db.find_keyspace(keyspace()).get_replication_strategy().uses_tablets()) { + throw exceptions::invalid_request_exception(format("Secondary indexes are not supported on base tables with tablets (keyspace '{}')", keyspace())); + } validate_for_local_index(*schema); std::vector<::shared_ptr> targets; diff --git a/cql3/statements/create_view_statement.cc b/cql3/statements/create_view_statement.cc index f934c30346..e5ba3c6127 100644 --- a/cql3/statements/create_view_statement.cc +++ b/cql3/statements/create_view_statement.cc @@ -140,6 +140,9 @@ std::pair create_view_statement::prepare_view( schema_ptr schema = validation::validate_column_family(db, _base_name.get_keyspace(), _base_name.get_column_family()); + if (!db.features().views_with_tablets && db.find_keyspace(keyspace()).get_replication_strategy().uses_tablets()) { + throw exceptions::invalid_request_exception(format("Materialized views are not supported on base tables with tablets")); + } if (schema->is_counter()) { throw exceptions::invalid_request_exception(format("Materialized views are not supported on counter tables")); }