Area: Ingestion
Sub-Area: Databases
Applies to: OSS + Cloud
Issue
Postgres ingestion does not discover all schemas or tables. Some tables that exist in the database are missing from DataHub.
You Might Be Asking
- Why are some of my Postgres tables missing?
- How do I ingest from multiple Postgres schemas or multiple databases?
- How do I set up RDS IAM authentication, view lineage and profiling without breaking my recipe?
Cause
- The
postgressource appliesschema_patternwith a default ofdeny: [information_schema]. If you setschema_patternin your recipe, your value replaces that default. - Patterns match from the start of the name only.
prodmatchesprod,prod_eastandproduction. Anchor with^...$for an exact match. Matching ignores case by default. - Deny is checked first. A name that matches both
allowanddenyis excluded. -
table_patternmatches the fulldatabase.schema.tablename. - If you set
database(orsqlalchemy_uri), the source inspects only that database and does not usedatabase_pattern.
Solution
- Set
schema_patternandtable_pattern. Keepinformation_schemain the deny list, because yourschema_patternreplaces the default:
source:
type: postgres
config:
host_port: "postgres.company.com:5432"
database: "your_database"
username: "${POSTGRES_USER}"
password: "${POSTGRES_PASSWORD}"
schema_pattern:
allow: ["^public$", "^analytics$", "^staging$"]
deny: ["^information_schema$"]
table_pattern:
allow: [".*"]
deny: [".*_temp$", ".*_backup$"]
- To ingest several databases, remove
databaseandsqlalchemy_uri. The source connects toinitial_database(defaultpostgres), lists the databases frompg_database(excludingtemplate0,template1andrdsadmin), keeps the ones thatdatabase_patternallows, and opens a separate connection to each:
source:
type: postgres
config:
host_port: "postgres.company.com:5432"
username: "${POSTGRES_USER}"
password: "${POSTGRES_PASSWORD}"
initial_database: "postgres"
database_pattern:
allow: ["^sales$", "^analytics$"]
- For RDS Postgres with IAM authentication, use
auth_mode: AWS_IAMand a nestedaws_configblock. Thepasswordfield is ignored in this mode. Do not use top-leveluse_iam_authoraws_regionkeys.
source:
type: postgres
config:
host_port: "database.region.rds.amazonaws.com:5432"
database: "your_database"
username: "datahub_user"
auth_mode: AWS_IAM
aws_config:
aws_region: "us-east-1"
With IAM, sslmode is raised to require unless it is already require, verify-ca or verify-full. To verify the server, set options.connect_args.sslmode: verify-full and options.connect_args.sslrootcert to the RDS CA bundle.
- View lineage is on by default.
include_view_lineageandinclude_view_column_lineageboth default totrue, andinclude_view_column_lineageneedsinclude_view_lineage. There is noparse_view_ddloption. To turn view handling off or on, use these keys:
source:
type: postgres
config:
include_tables: true
include_views: true
include_view_lineage: true
include_view_column_lineage: true
- Profiling is off by default (
profiling.enabled: false). To limit which tables and columns are profiled, use the source-levelprofile_pattern. There is noprofiling.allow_deny_patternskey.max_number_of_fields_to_profilecaps the number of columns profiled per table. It does not limit row scans.
source:
type: postgres
config:
profiling:
enabled: true
max_number_of_fields_to_profile: 20
profile_pattern:
allow: [".*analytics.*"]
Config models reject unknown keys, so check every key against the Postgres source page before you run the recipe. The profiler reads row-count estimates from pg_catalog.pg_class.reltuples. You do not need to grant access to pg_statistic for profiling.