QuackDB.DDL (quackdb v0.2.0)

Copy Markdown View Source

Small DuckDB DDL SQL builders.

These helpers return SQL iodata for common analytical setup tasks such as temporary tables in tests or notebooks. They are not an Ecto migration layer; execute the generated SQL with QuackDB.query/4 or Repo.query/3.

QuackDB.DDL.create_table("events",
  [
    id: :integer,
    name: :varchar,
    payload: :json,
    occurred_at: :timestamp
  ],
  temporary: true,
  if_not_exists: true
)

Summary

Functions

Builds a CREATE TABLE statement.

Builds a DROP TABLE statement.

Types

column()

@type column() ::
  {atom() | String.t(), column_type()}
  | {atom() | String.t(), column_type(), keyword()}

column_type()

@type column_type() :: QuackDB.Type.spec()

create_table_option()

@type create_table_option() :: {:temporary, boolean()} | {:if_not_exists, boolean()}

Functions

create_table(name, columns, options \\ [])

@spec create_table(String.t() | atom(), [column()], [create_table_option()]) ::
  iodata()

Builds a CREATE TABLE statement.

drop_table(name, options \\ [])

@spec drop_table(
  String.t() | atom(),
  keyword()
) :: iodata()

Builds a DROP TABLE statement.