diff --git a/cql3/restrictions/statement_restrictions.cc b/cql3/restrictions/statement_restrictions.cc index 4e2fb0d8db..44f903277a 100644 --- a/cql3/restrictions/statement_restrictions.cc +++ b/cql3/restrictions/statement_restrictions.cc @@ -37,6 +37,8 @@ namespace cql3 { namespace restrictions { +static logging::logger rlogger("restrictions"); + using boost::adaptors::filtered; using boost::adaptors::transformed; @@ -431,6 +433,33 @@ void statement_restrictions::validate_secondary_index_selections(bool selects_on } } +const single_column_restrictions::restrictions_map& statement_restrictions::get_single_column_partition_key_restrictions() const { + static single_column_restrictions::restrictions_map empty; + auto single_restrictions = dynamic_pointer_cast>(_partition_key_restrictions); + if (!single_restrictions) { + if (dynamic_pointer_cast>(_partition_key_restrictions)) { + return empty; + } + throw std::runtime_error("statement restrictions for multi-column partition key restrictions are not implemented yet"); + } + return single_restrictions->restrictions(); +} + +/** + * @return clustering key restrictions split into single column restrictions (e.g. for filtering support). + */ +const single_column_restrictions::restrictions_map& statement_restrictions::get_single_column_clustering_key_restrictions() const { + static single_column_restrictions::restrictions_map empty; + auto single_restrictions = dynamic_pointer_cast>(_clustering_columns_restrictions); + if (!single_restrictions) { + if (dynamic_pointer_cast>(_clustering_columns_restrictions)) { + return empty; + } + throw std::runtime_error("statement restrictions for multi-column partition key restrictions are not implemented yet"); + } + return single_restrictions->restrictions(); +} + static std::optional do_get_value(const schema& schema, const column_definition& cdef, const partition_key& key, diff --git a/cql3/restrictions/statement_restrictions.hh b/cql3/restrictions/statement_restrictions.hh index 1c8b34f1fc..7fcb5efde0 100644 --- a/cql3/restrictions/statement_restrictions.hh +++ b/cql3/restrictions/statement_restrictions.hh @@ -399,6 +399,16 @@ public: const single_column_restrictions::restrictions_map& get_non_pk_restriction() const { return _nonprimary_key_restrictions->restrictions(); } + + /** + * @return partition key restrictions split into single column restrictions (e.g. for filtering support). + */ + const single_column_restrictions::restrictions_map& get_single_column_partition_key_restrictions() const; + + /** + * @return clustering key restrictions split into single column restrictions (e.g. for filtering support). + */ + const single_column_restrictions::restrictions_map& get_single_column_clustering_key_restrictions() const; }; }