# `QuackDB.SQL.Fragment`
[🔗](https://github.com/elixir-vibe/quackdb/blob/main/lib/quack_db/sql/fragment.ex#L1)

Reusable SQL fragments shared by QuackDB statement builders.

This module intentionally builds small, composable iodata fragments rather than
introducing another statement-level DSL. Public DML/DDL helpers can reuse these
fragments while keeping the number of top-level insert/update APIs small.

# `alias_name`

```elixir
@type alias_name() :: atom() | String.t()
```

# `column`

```elixir
@type column() :: atom() | String.t()
```

# `identifier_name`

```elixir
@type identifier_name() :: atom() | String.t()
```

# `nulls_order`

```elixir
@type nulls_order() :: :first | :last
```

# `order_direction`

```elixir
@type order_direction() :: :asc | :desc
```

# `order_expression`

```elixir
@type order_expression() ::
  column()
  | {column(), order_direction()}
  | {column(), order_direction(), keyword()}
```

# `schema`

```elixir
@type schema() :: identifier_name() | [identifier_name()]
```

# `table`

```elixir
@type table() :: identifier_name() | {schema() | nil, identifier_name()}
```

# `alias_name`

```elixir
@spec alias_name(alias_name()) :: iodata()
```

Quotes a table alias.

# `as`

```elixir
@spec as(iodata(), column()) :: iodata()
```

Renders `expression AS alias`.

# `check_constraint`

```elixir
@spec check_constraint(QuackDB.DDL.Check.t()) :: iodata()
```

Renders an inline CHECK built by `QuackDB.DDL.check/1`.

# `column`

```elixir
@spec column(column()) :: iodata()
```

Quotes a column identifier.

# `column_list`

```elixir
@spec column_list([column()]) :: iodata()
```

Renders a comma-separated column list.

# `conflict_target`

```elixir
@spec conflict_target([column()]) :: iodata()
```

Renders a conflict target such as `(id, name)`, including trailing space.

# `insert_columns`

```elixir
@spec insert_columns([column()]) :: iodata()
```

Renders an optional parenthesized insert column list.

# `join`

```elixir
@spec join(:inner | :left, table(), keyword()) :: iodata()
```

Renders a simple joined table clause.

# `on_conflict`

```elixir
@spec on_conflict(:raise | :nothing | {:nothing, [column()]}) :: iodata()
```

Renders supported `ON CONFLICT` clauses.

# `order_by`

```elixir
@spec order_by([order_expression()]) :: iodata()
```

Renders an optional `ORDER BY` clause for window expressions.

# `partition_by`

```elixir
@spec partition_by([column()]) :: iodata()
```

Renders a parenthesized window partition column list.

# `qualified_column`

```elixir
@spec qualified_column(alias_name(), column()) :: iodata()
```

Quotes a qualified column reference such as `source.id`.

# `qualified_column_list`

```elixir
@spec qualified_column_list([column()], alias_name()) :: iodata()
```

Renders a comma-separated qualified column list.

# `qualified_equality`

```elixir
@spec qualified_equality(alias_name(), column(), alias_name(), column()) :: iodata()
```

Renders equality between two qualified columns.

# `qualified_not_distinct`

```elixir
@spec qualified_not_distinct(alias_name(), column(), alias_name(), column()) ::
  iodata()
```

Renders `IS NOT DISTINCT FROM` between two qualified columns.

# `returning`

```elixir
@spec returning([column()]) :: iodata()
```

Renders `RETURNING ...` for a non-empty column list.

# `row_number_over`

```elixir
@spec row_number_over(keyword()) :: iodata()
```

Renders a `row_number() OVER (...) AS alias` expression.

# `schema`

```elixir
@spec schema(schema()) :: iodata()
```

Quotes a schema name or a nested schema path such as `[:finance, :reports]`.

# `select`

```elixir
@spec select(
  [iodata()],
  keyword()
) :: iodata()
```

Builds a small `SELECT` query fragment.

# `select_columns`

```elixir
@spec select_columns([column()]) :: iodata()
```

Renders `*` for an empty select list, otherwise a column list.

# `table`

```elixir
@spec table(table()) :: iodata()
```

Quotes a table name, optionally with a schema/prefix tuple.

A list prefix names a nested schema path, as in DuckDB 2.0's
`finance.reports.ledger`.

# `union`

```elixir
@spec union(
  [iodata()],
  keyword()
) :: iodata()
```

Combines queries with `UNION` or `UNION ALL`, with optional ordering.

# `where`

```elixir
@spec where(nil | iodata()) :: iodata()
```

Renders an optional `WHERE` clause from raw predicate iodata.

---

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