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 from an Ecto schema module.
Builds a CREATE TABLE statement.
Builds a CREATE TABLE AS statement.
Builds a DROP TABLE statement.
Types
@type column() :: {atom() | String.t(), column_type()} | {atom() | String.t(), column_type(), keyword()}
@type column_type() :: QuackDB.Type.spec()
Functions
Builds a CREATE TABLE statement from an Ecto schema module.
@spec create_table(String.t() | atom(), [column()], [create_table_option()]) :: iodata()
Builds a CREATE TABLE statement.
QuackDB.DDL.create_table("events", id: :integer, name: :varchar)
QuackDB.DDL.create_table("events", [id: :integer], temporary: true)Pass :as to build CREATE TABLE AS from iodata or an Ecto query without pinned params:
QuackDB.DDL.create_table("docs", as: query, temporary: true)
@spec create_table_as(String.t() | atom(), iodata(), [create_table_option()]) :: iodata()
Builds a CREATE TABLE AS statement.
Builds a DROP TABLE statement.