QuackDB.Type (quackdb v0.5.3)

Copy Markdown View Source

DuckDB SQL type rendering shared by DDL and source helpers.

The protocol codec has its own logical type metadata for decoding wire values. This module is the SQL-facing counterpart: it renders user-friendly type specs into DuckDB type names for generated SQL.

Summary

Functions

Parses a DuckDB SQL type name into a QuackDB type spec.

Renders an identifier with DuckDB SQL quoting.

Renders a DuckDB SQL type spec as iodata.

Types

spec()

@type spec() ::
  atom()
  | String.t()
  | {:varchar, pos_integer()}
  | {:char, pos_integer()}
  | {:decimal, pos_integer(), non_neg_integer()}
  | {:list, spec()}
  | {:array, spec(), pos_integer()}
  | {:map, spec(), spec()}
  | {:struct, keyword(spec()) | map()}

Functions

from_sql(type)

@spec from_sql(String.t()) ::
  {:ok, spec()} | {:error, {:unsupported_sql_type, String.t()}}

Parses a DuckDB SQL type name into a QuackDB type spec.

quote_identifier(value)

@spec quote_identifier(atom() | String.t()) :: iodata()

Renders an identifier with DuckDB SQL quoting.

to_sql(type)

@spec to_sql(spec()) :: iodata()

Renders a DuckDB SQL type spec as iodata.