PostgreSQL
Configuration reference for the PostgreSQL metadata source: supported stages, source options, required grants, and troubleshooting.
PostgreSQL is supported as a metadata source. A spec.type: metadata pipeline introspects a PostgreSQL database and publishes source context: databases, schemas, tables, views, columns, profiles, lineage, usage, and classification. It does not copy table rows.
For batch row movement out of PostgreSQL, see the PostgreSQL (batch); for change data capture, see the PostgreSQL (CDC). For the field-by-field authoring contract, see Metadata pipeline config.
Metadata stages
service_type: postgres supports the full DAG. The required mode field decides how much of it runs: shallow runs metadata + lineage; deep adds profiler, classification, and usage. Source inventory (metadata) runs first; once it succeeds, the remaining stages run in parallel.
metadata
shallow, deep
Databases, schemas, tables, views, partitioned tables, foreign tables, columns (with data types, nullability, defaults), primary/foreign-key constraints, and object descriptions (comments).
lineage
shallow, deep
Asset and column lineage parsed from view definitions and, when query statistics are available, from the query log.
profiler
deep
Per-column statistics (row counts, null counts, distinct counts, min/max, basic distributions) and table-level metrics.
classification
deep
Auto-classification tags applied to columns from sampled data (PII heuristics).
usage
deep
Query popularity and access frequency derived from query statistics.
The first successful run establishes the source inventory and lineage. In deep, profiles, classification, and usage then deepen it. A frequent shallow pipeline keeps inventory and lineage fresh; pair it with a less frequent deep pipeline for the full profile.
Asset hierarchy
PostgreSQL assets map into the Datasets App as Database → Schema → Table/View → Column. Partitioned tables surface as a single logical table; foreign tables (postgres_fdw and similar) surface as tables with their remote definition captured.
Source options
Metadata pipelines accept only the customer-facing source.options keys below. Do not set source_table. Nilus assigns a stage-specific value to each DAG node internally.
service_type
Yes
all
Must be postgres (alias postgresql).
database_filter
No
see below
Optional include/exclude regexes. Ignored for inventory: PostgreSQL always binds one database. On classification / profiler, resolved against databases already in the catalog.
schema_filter
No
all
Restrict by schema name. Same shape as database_filter.
table_filter
No
all
Restrict by table / view name. Same shape as database_filter.
query_log_duration
No
lineage, usage
Days of query statistics to ingest per run. Defaults to 1. Used by lineage (both modes) and usage (deep only).
result_limit
No
lineage, usage
Maximum number of query rows to fetch per run. Defaults to 10000000. Used by lineage (both modes) and usage (deep only).
threads
No
profiler, usage
Parallel worker count for the heavier stages. Raise it to cut runtime on large scopes.
Required permissions
A metadata pipeline needs read access to the catalog and, for the enrichment stages, to the data and query statistics:
CONNECTon the target database andUSAGEon the schemas in scope;SELECTon the tables and views in scope. This is required formetadata(constraint reflection),profiler, andclassification(which sample rows).for
lineageandusage, access to query statistics through thepg_stat_statementsextension. Grant the login thepg_read_all_stats(orpg_monitor) role so it can read the statement statistics view.
Example grant pattern for a dedicated metadata login:
Sample Nilus config
Project credentials through spec.use.projection:
With mode: deep, the depot-backed resource above produces a five-node DAG (metadata root → lineage, profiler, classification, usage). Switch to mode: shallow for a 2-node metadata + lineage DAG. For more ready-to-edit examples, see Metadata sample configs.
Behavior and capabilities
Connection: Use a PostgreSQL depot (
dataos://<depot>?purpose=rw) or a directpostgresql://...URI with projected credentials. Becausespec.typeismetadata, Nilus adds the internalmetadata+routing prefix automatically. A depot bundles host, port, database, and TLS material with the credentials in one place. Add?sslmode=require(orverify-ca/verify-full) to the direct URI for TLS;sslmodedefaults todisablewhen omitted. Both the depot and URI require a database. Omitting it from a URI fails validation before a connection is attempted. PostgreSQL has no account-level scan.database_filterdoes not change inventory: Themetadatastage always scans the bound database. Extraincludesnames do not add databases to inventory. Onclassification/profiler, a multi-entry filter is honoured for every named database already in the catalog, including one this connection is not bound to. A name that is not catalogued is a no-op. With no filter, classification stays in the bound database rather than roaming the catalog. See Howdatabase_filteris evaluated.Identifier case: PostgreSQL folds unquoted identifiers to lower-case. Use lower-case forms in filter patterns to match how objects are reported.
Scope discipline: Bound inventory with
schema_filter/table_filter. Excludepg_catalog,information_schema, and temporary/audit schemas.Query statistics: Lineage and usage read from
pg_stat_statements. Without the extension, inventory and profiling still succeed but lineage/usage output will be empty.
Troubleshooting
FATAL: password authentication failed
Wrong username/password, or the login lacks CONNECT.
Verify the projected secret and GRANT CONNECT ON DATABASE.
SSL connection required / TLS errors
Server enforces TLS but the URI omits sslmode.
Add ?sslmode=require (or verify-ca / verify-full) to the URI.
Inventory lands but lineage/usage are empty
pg_stat_statements is not enabled, or the login can't read it.
Enable the extension and grant pg_read_all_stats (or pg_monitor).
Profiler/classification skip tables
The login has catalog visibility but no SELECT on the data.
Grant SELECT on the tables in scope (and set default privileges for new tables).
A stage runs for hours
The extraction scope is unbounded.
Tighten schema_filter / table_filter; raise threads. database_filter does not shrink inventory.
Extra databases in includes never appear in inventory
PostgreSQL always binds one database.
Inventory is the URI/depot database. Extra names only affect classification/profiler if those databases are already in the catalog.
Related Docs
PostgreSQL: Batch row movement out of PostgreSQL.
PostgreSQL: Log-based change capture.
Metadata sources: All metadata-capable sources and how to scope extraction.
Metadata pipelines: The conceptual model.
Metadata pipeline config: The
spec.type: metadatacontract and DAG anatomy.Metadata sample configs: Ready-to-edit YAML.
Last updated
Was this helpful?