Query building functions for AshScylla data layer.
Provides optimized query building with filter-to-CQL conversion, prepared statement support, and token-based pagination.
Secondary Index Support
When filtering on non-primary key columns, this module checks if a secondary index exists and generates appropriate CQL. ScyllaDB/Cassandra can use secondary indexes for equality checks (=) but not for range queries.
Summary
Functions
Builds an optimized CQL query from the data layer query struct.
Builds ORDER BY clause from sort items.
Builds WHERE clause from Ash filters.
Checks if a filter can use secondary indexes.
Converts Ash filter expressions to CQL.
Functions
@spec build_optimized_query(AshScylla.DataLayer.t()) :: {String.t(), list()}
Builds an optimized CQL query from the data layer query struct.
If filters are on columns with secondary indexes, the query will use those indexes automatically.
Builds ORDER BY clause from sort items.
Builds WHERE clause from Ash filters.
Checks if a filter can use secondary indexes.
Returns {:ok, indexed_columns} if the filter can use indexes,
or {:error, reason} if it cannot.
Converts Ash filter expressions to CQL.
Note: For secondary indexes to be used, filters should be equality checks on indexed columns. Range queries on secondary indexes are not recommended.