EctoDBScanner.EnumDetector (EctoDBScanner v0.4.0)

Copy Markdown View Source

Detects enum-like columns via PostgreSQL ENUM types and heuristic analysis.

Summary

Functions

Detects enum-like string columns using cardinality heuristics. Returns %{{schema, table, column} => ["val1", "val2", ...]}.

Queries pg_type/pg_enum catalogs for all defined PostgreSQL ENUM types. Returns %{"type_name" => ["val1", "val2", ...]}.

Functions

detect_heuristic_enums(repo, tables_with_counts, columns, opts \\ [])

Detects enum-like string columns using cardinality heuristics. Returns %{{schema, table, column} => ["val1", "val2", ...]}.

Options

  • :max_concurrency — number of columns to sample in parallel. Defaults to pool_size - 1 (minimum 1) when :pool_size is given, otherwise to the system schedulers count.
  • :pool_size — repo pool size used to derive :max_concurrency when the latter is not set explicitly.
  • :timeout — per-column sampling timeout in milliseconds. Defaults to 60_000. A column whose sampling exceeds this is dropped from the results; it does not abort the rest of the run.

query_pg_enums(repo)

Queries pg_type/pg_enum catalogs for all defined PostgreSQL ENUM types. Returns %{"type_name" => ["val1", "val2", ...]}.