diff --git a/cql3/restrictions/statement_restrictions.cc b/cql3/restrictions/statement_restrictions.cc
index 9438d03f4e..c9794952e7 100644
--- a/cql3/restrictions/statement_restrictions.cc
+++ b/cql3/restrictions/statement_restrictions.cc
@@ -754,7 +754,7 @@ void statement_restrictions::add_single_column_parition_key_restriction(const ex
}
void statement_restrictions::add_token_partition_key_restriction(const expr::binary_operator& restr) {
- if (!expr::is_empty_restriction(_new_partition_key_restrictions) && !has_token(_new_partition_key_restrictions)) {
+ if (!partition_key_restrictions_is_empty() && !has_token(_new_partition_key_restrictions)) {
throw exceptions::invalid_request_exception(
format("Columns \"{}\" cannot be restricted by both a normal relation and a token relation",
join(", ", expr::get_sorted_column_defs(_new_partition_key_restrictions))));
@@ -863,7 +863,7 @@ void statement_restrictions::process_partition_key_restrictions(bool for_view, b
// components must have a EQ. Only the last partition key component can be in IN relation.
if (has_token(_partition_key_restrictions->expression)) {
_is_key_range = true;
- } else if (_partition_key_restrictions->empty()) {
+ } else if (expr::is_empty_restriction(_new_partition_key_restrictions)) {
_is_key_range = true;
_uses_secondary_indexing = _has_queriable_pk_index;
}
@@ -884,6 +884,10 @@ bool statement_restrictions::has_partition_key_unrestricted_components() const {
return _partition_key_restrictions->has_unrestricted_components(*_schema);
}
+bool statement_restrictions::partition_key_restrictions_is_empty() const {
+ return expr::is_empty_restriction(_new_partition_key_restrictions);
+}
+
bool statement_restrictions::has_unrestricted_clustering_columns() const {
return _clustering_columns_restrictions->has_unrestricted_components(*_schema);
}
diff --git a/cql3/restrictions/statement_restrictions.hh b/cql3/restrictions/statement_restrictions.hh
index 06c3cbf715..ae43d99b33 100644
--- a/cql3/restrictions/statement_restrictions.hh
+++ b/cql3/restrictions/statement_restrictions.hh
@@ -223,6 +223,8 @@ public:
*/
bool has_partition_key_unrestricted_components() const;
+ bool partition_key_restrictions_is_empty() const;
+
/**
* Checks if the clustering key has some unrestricted components.
* @return true if the clustering key has some unrestricted components, false otherwise.
diff --git a/cql3/statements/select_statement.cc b/cql3/statements/select_statement.cc
index 2c5d69c68e..e384dfd580 100644
--- a/cql3/statements/select_statement.cc
+++ b/cql3/statements/select_statement.cc
@@ -858,7 +858,7 @@ primary_key_select_statement::primary_key_select_statement(schema_ptr schema, ui
{
if (_ks_sel == ks_selector::NONSYSTEM) {
if (_restrictions->need_filtering() ||
- _restrictions->get_partition_key_restrictions()->empty() ||
+ _restrictions->partition_key_restrictions_is_empty() ||
(has_token(_restrictions->get_partition_key_restrictions()->expression) &&
!find(_restrictions->get_partition_key_restrictions()->expression, expr::oper_t::EQ))) {
_range_scan = true;