An Ash data layer for ScyllaDB using Xandra (direct CQL driver).
This data layer implements the Ash.DataLayer behaviour to allow Ash resources
to be backed by ScyllaDB/Cassandra.
Configuration
Configure your resource to use this data layer:
defmodule MyApp.MyResource do
use Ash.Resource,
data_layer: AshScylla.DataLayer
attributes do
uuid_primary_key :id
attribute :name, :string
end
relationships do
# Define relationships as needed
end
endFeatures Supported
:create- Create records:read- Read records with filtering:update- Update records:destroy- Delete records:filter- Filter queries:limit- Limit results:select- Select specific fields:multitenancy- Keyspace-based multitenancy:upsert- Upsert records (INSERT IF NOT EXISTS with LWT):update_query- Bulk update via filtered queries:destroy_query- Bulk delete via filtered queries:keyset- Token-based keyset pagination (the default pagination mode):distinct- DISTINCT on partition key columns{:aggregate, :count}- Per-partition COUNT aggregates{:atomic, :update}- Atomic updates via LWT (IF clauses){:atomic, :upsert}- Atomic upserts via LWT:boolean_filter- OR filter rewriting to IN where possible
Limitations
Since ScyllaDB/Cassandra is a wide-column store, not all SQL features are supported:
- No JOINs (use denormalization or multiple queries)
- Expression calculations are done in Elixir post-processing (not in-database)
- DISTINCT only works on partition key columns
- Limited aggregation support
- Combination queries (UNION/INTERSECT) are not supported
- No transactions across partitions (lightweight transactions only)
- Locking is a no-op (use LWT for conditional operations)
- No complex WHERE clauses on non-primary key columns without secondary indexes
- Cross-partition aggregates require materialized views
- CQL ORDER BY only works on clustering columns within a partition
Summary
Functions
Computes the meta map for a list of resources.
Filters a list of resources to only those whose schema has changed compared to the previous meta map.
Loads the codegen meta file from disk.
Merges previous meta with updated entries for changed resources.
Returns the qualified table name (with keyspace prefix if configured).
Saves the codegen meta map to disk.
Types
@type t() :: AshScylla.Query.t()
Functions
Computes the meta map for a list of resources.
Returns a map of resource_key => schema_hash that can be used to detect changes between runs.
Filters a list of resources to only those whose schema has changed compared to the previous meta map.
Returns the list of changed resources.
Loads the codegen meta file from disk.
Returns an empty map if the file doesn't exist or can't be parsed.
Merges previous meta with updated entries for changed resources.
Returns the qualified table name (with keyspace prefix if configured).
Examples
iex> AshScylla.DataLayer.qualified_table(MyResource)
"test_ks.my_table"
Saves the codegen meta map to disk.
@spec upsert(Ash.Resource.t(), Ash.Changeset.t()) :: {:ok, Ash.Resource.t()} | {:error, term()}