Validates that filter columns are queryable in ScyllaDB/Cassandra.
ScyllaDB/Cassandra requires that WHERE clause columns are either:
- Part of the primary key
- Have a secondary index defined
Filtering on non-indexed columns would require ALLOW FILTERING, which
is an anti-pattern that causes full cluster scans. This module catches
such issues at query-build time and provides actionable error messages.
Summary
Functions
Returns the list of columns that are safe to filter on for a resource.
Validates that all filter columns on a resource are queryable.
Functions
Returns the list of columns that are safe to filter on for a resource.
Validates that all filter columns on a resource are queryable.
Returns :ok if all filters are on primary key columns or indexed columns.
Raises AshScylla.Error with an actionable message if a filter would
require ALLOW FILTERING.
Parameters
resource- The Ash resource modulefilters- List of Ash filter expressions
Examples
AshScylla.DataLayer.FilterValidator.validate_filters(MyApp.User, filters)
# => :ok
AshScylla.DataLayer.FilterValidator.validate_filters(MyApp.User, [{:non_indexed_col, :eq, "value"}])
# => raises AshScylla.Error with suggestion to add secondary_index