# `AshClickhouse.DataLayer.Dsl.Macros`
[🔗](https://github.com/ohhi-vn/ash_clickhouse/blob/main/lib/ash_clickhouse/data_layer/dsl/macros.ex#L1)

Compile-time macros for the ClickHouse DSL.

This module only contains the `clickhouse/1` macro (and its private helpers).
It is intentionally kept separate from `AshClickhouse.DataLayer.Dsl` so that
importing it does not also import the runtime getter functions (such as
`table/1`). That separation matters: a resource may define a local helper
macro or function named like a DSL key (e.g. `table/1`) inside a `clickhouse`
block value, and we must not shadow it with an imported getter.

# `clickhouse`
*macro* 

```elixir
@spec clickhouse(keyword()) :: Macro.t()
```

Macro for configuring ClickHouse options in Ash resources.

Import this module (and only this module) to use the `clickhouse` block:

    import AshClickhouse.DataLayer.Dsl.Macros

    clickhouse do
      table "my_table"
      repo MyApp.Repo
      engine "MergeTree()"
      order_by "id"

      # Data-skipping indexes (ClickHouse has no B-tree indexes). May be
      # repeated; each becomes an `INDEX ... TYPE ... GRANULARITY ...` in the
      # table DDL. `granularity` defaults to 1.
      index name: :idx_user_id, expression: "user_id", type: "bloom_filter"
      index name: :idx_created_at, expression: "created_at", type: "minmax", granularity: 4
    end

The runtime getters (e.g. `AshClickhouse.DataLayer.Dsl.table/1`) live in
`AshClickhouse.DataLayer.Dsl` and are not imported by this module.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
