AshClickhouse.DataLayer.Dsl (AshClickhouse v0.1.0)

Copy Markdown View Source

DSL extensions for configuring ClickHouse-specific options on Ash resources.

Usage

defmodule MyApp.MyResource do
  use Ash.Resource,
    data_layer: AshClickhouse.DataLayer

  clickhouse do
    table "my_table"
    repo MyApp.Repo
    database "my_app_dev"

    base_filter [status: "active"]
    default_context %{tenant: "org_123"}
    description "My resource description"

    engine "MergeTree()"
    order_by "id"
    partition_by "toYYYYMM(inserted_at)"

    settings "index_granularity = 8192"
  end

  attributes do
    uuid_primary_key :id
    attribute :name, :string
  end
end

Options

  • :table — the table name in ClickHouse (overrides the default)
  • :repo — the AshClickhouse.Repo module to use
  • :database — the database to use (overrides repo default)
  • :engine — the ClickHouse table engine (default "MergeTree()")
  • :order_byORDER BY expression for the table engine
  • :partition_byPARTITION BY expression for the table engine
  • :primary_key — explicit primary key columns (ClickHouse PRIMARY KEY)
  • :settings — engine settings string
  • :base_filter — a filter applied to all queries on this resource
  • :default_context — context merged into every query/changeset
  • :description — human-readable description of the resource
  • :migrate — whether this resource is included in migrations (default true)

Summary

Functions

The configured base_filter.

Macro for configuring ClickHouse options in Ash resources.

The configured database (overrides repo default).

The configured default_context.

The configured description.

The configured table engine.

Whether this resource is included in migrations (default true).

The configured ORDER BY expression.

The configured PARTITION BY expression.

The configured explicit PRIMARY KEY columns.

The configured repo module.

The configured engine settings string.

The configured table name.

Functions

base_filter(resource)

@spec base_filter(module()) :: term() | nil

The configured base_filter.

clickhouse(list)

(macro)
@spec clickhouse(keyword()) :: Macro.t()

Macro for configuring ClickHouse options in Ash resources.

database(resource)

@spec database(module()) :: String.t() | nil

The configured database (overrides repo default).

default_context(resource)

@spec default_context(module()) :: map() | nil

The configured default_context.

description(resource)

@spec description(module()) :: String.t() | nil

The configured description.

engine(resource)

@spec engine(module()) :: String.t()

The configured table engine.

migrate?(resource)

@spec migrate?(module()) :: boolean()

Whether this resource is included in migrations (default true).

order_by(resource)

@spec order_by(module()) :: String.t() | nil

The configured ORDER BY expression.

partition_by(resource)

@spec partition_by(module()) :: String.t() | nil

The configured PARTITION BY expression.

primary_key(resource)

@spec primary_key(module()) :: [atom()] | nil

The configured explicit PRIMARY KEY columns.

repo(resource)

@spec repo(module()) :: module() | nil

The configured repo module.

settings(resource)

@spec settings(module()) :: String.t() | nil

The configured engine settings string.

table(resource)

@spec table(module()) :: String.t() | nil

The configured table name.