From ef8c60af36ea31d3eb103884cc60759205458d12 Mon Sep 17 00:00:00 2001 From: "neha.marne" Date: Thu, 26 Nov 2026 14:16:12 +0530 Subject: [PATCH 01/10] feat(ingest/postgres): add include_table_partitions to skip table partitions Each partition of a declaratively partitioned table (PARTITION BY, Postgres 10+) is listed by SQLAlchemy as a regular table, so it was ingested as its own dataset next to the parent. Tables partitioned by day or month produce hundreds of near-duplicate datasets, and the only workaround was a table_pattern deny regex that has to track partition naming. Add include_table_partitions (default true, so existing recipes are unchanged). When false, the Postgres source drops tables marked pg_class.relispartition, including sub-partitions, from both table ingestion and profiling, and keeps the parent table. Child tables created with INHERITS are not partitions and are still ingested. If partitions cannot be listed (pre-10 server, no pg_catalog access), a warning is reported and all tables are ingested as before. - sql_common: add a _get_table_names hook, mirroring _get_view_names, used by loop_tables and loop_profiler_requests. The base version is unchanged behavior for every other SQL source. - sql_report: add num_table_partitions_skipped and table_partitions_skipped. - Tests: unit tests for the filter, and a partitioned schema plus a recipe with the option off in the Postgres integration suite. The new tables are analyzed in setup.sql so profiling row-count estimates stay non-negative. - Docs: "Partitioned tables" section in postgres_post.md. Co-Authored-By: Claude Opus 5.5 --- .../docs/sources/postgres/postgres_post.md | 18 + .../ingestion/source/sql/postgres/query.py | 17 + .../ingestion/source/sql/postgres/source.py | 52 + .../ingestion/source/sql/sql_common.py | 10 +- .../ingestion/source/sql/sql_report.py | 5 + .../postgres_all_db_with_db_golden.json | 1086 +++++++++++++++++ ...postgres_skip_table_partitions_golden.json | 629 ++++++++++ ...postgres_skip_table_partitions_to_file.yml | 17 + .../postgres/postgres_with_db_golden.json | 1041 ++++++++++++++++ .../integration/postgres/setup/setup.sql | 26 + .../integration/postgres/test_postgres.py | 19 + .../tests/unit/test_postgres_source.py | 70 ++ 12 files changed, 2988 insertions(+), 2 deletions(-) create mode 100644 metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_golden.json create mode 100644 metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_to_file.yml diff --git a/metadata-ingestion/docs/sources/postgres/postgres_post.md b/metadata-ingestion/docs/sources/postgres/postgres_post.md index fc2072c0030d..ee705e850ff5 100644 --- a/metadata-ingestion/docs/sources/postgres/postgres_post.md +++ b/metadata-ingestion/docs/sources/postgres/postgres_post.md @@ -184,6 +184,24 @@ Navigate to a dataset in DataHub and check the "Lineage" tab. You should see ups - Run ingestion daily or weekly to capture lineage from new queries - More frequent ingestion provides more up-to-date lineage graphs +#### Partitioned tables + +By default, each partition of a declaratively partitioned table (`PARTITION BY`, PostgreSQL 10+) is ingested as its own dataset, alongside the parent table. For tables partitioned by day or month, this can add hundreds of near-duplicate datasets. + +To ingest only the parent table and skip its partitions, set `include_table_partitions` to `false`: + +```yaml +source: + type: postgres + config: + # ... + include_table_partitions: false +``` + +Partitions are detected through `pg_class.relispartition`, so new partitions are skipped automatically without updating `table_pattern`. Sub-partitions are skipped too. The ingestion report lists skipped partitions under `num_table_partitions_skipped` and `table_partitions_skipped`. + +Child tables created with table inheritance (`INHERITS`) are not partitions and are always ingested. Use `table_pattern` to exclude them. + ### Limitations Module behavior is constrained by source APIs, permissions, and metadata exposed by the platform. Refer to capability notes for unsupported or conditional features. diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py index 738b712252b0..01e1af8adad0 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py @@ -47,6 +47,23 @@ def _build_pg_stat_filter( return " AND ".join(filters) + @staticmethod + def get_table_partitions() -> TextClause: + """List tables in a schema that are partitions of a partitioned table. + + relispartition was added in Postgres 10, alongside declarative + partitioning. Use with: connection.execute(query, {"schema": schema}) + """ + return text( + """ + SELECT c.relname AS table_name + FROM pg_catalog.pg_class c + JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace + WHERE n.nspname = :schema + AND c.relispartition + """ + ) + @staticmethod def check_pg_stat_statements_enabled() -> TextClause: """Check if pg_stat_statements extension is installed.""" diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py index d0ea6f20d103..16f575b4f1c9 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py @@ -9,6 +9,7 @@ Iterable, List, Optional, + Set, Tuple, Type, Union, @@ -421,6 +422,17 @@ class PostgresConfig(BasePostgresConfig, BaseUsageConfig): "Specify regex to match the entire procedure name in database.schema.procedure_name format. e.g. to match all procedures starting with customer in Customer database and public schema, use the regex 'Customer.public.customer.*'", ) + include_table_partitions: bool = Field( + default=True, + description=( + "Ingest each partition of a declaratively partitioned table " + "(PARTITION BY, Postgres 10+) as its own dataset. Set to false to " + "ingest only the parent partitioned table and skip its partitions. " + "Child tables created with table inheritance (INHERITS) are not " + "partitions and are always ingested; use table_pattern to exclude them." + ), + ) + include_query_lineage: bool = Field( default=False, description=( @@ -577,6 +589,10 @@ def __init__(self, config: PostgresConfig, ctx: PipelineContext): config.rds_iam_token_manager() ) + # loop_tables and loop_profiler_requests both list tables, so a skipped + # partition is seen twice per run; this keeps the report count exact. + self._skipped_table_partitions: Set[str] = set() + self.sql_aggregator: Optional[SqlParsingAggregator] = None if self.config.include_query_lineage: # Validate graph connection requirement for usage statistics @@ -741,6 +757,42 @@ def _get_view_names(self, inspector: Inspector, schema: str) -> List[str]: name for name in materialized_view_names if name not in known ] + def _get_table_names(self, inspector: Inspector, schema: str) -> List[str]: + table_names = super()._get_table_names(inspector, schema) + if self.config.include_table_partitions: + return table_names + try: + with inspector.engine.connect() as conn: + partitions = { + row.table_name + for row in conn.execute( + PostgresQuery.get_table_partitions(), {"schema": schema} + ) + } + except Exception as e: + self.report.warning( + title="Failed to list table partitions", + message="Partitions in this schema will be ingested as regular tables. " + "Detecting partitions requires Postgres 10+ and read access to pg_catalog.", + context=schema, + exc=e, + ) + return table_names + + kept: List[str] = [] + for table in table_names: + if table not in partitions: + kept.append(table) + continue + dataset_name = self.get_identifier( + schema=schema, entity=table, inspector=inspector + ) + if dataset_name not in self._skipped_table_partitions: + self._skipped_table_partitions.add(dataset_name) + self.report.num_table_partitions_skipped += 1 + self.report.table_partitions_skipped.append(dataset_name) + return kept + def get_workunits_internal(self) -> Iterable[Union[MetadataWorkUnit, SqlWorkUnit]]: yield from super().get_workunits_internal() diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/sql_common.py b/metadata-ingestion/src/datahub/ingestion/source/sql/sql_common.py index cdde3e4c74c3..4878d5c5a567 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/sql_common.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/sql_common.py @@ -780,7 +780,7 @@ def loop_tables( data_reader = self.make_data_reader(inspector) with data_reader or contextlib.nullcontext(): try: - for table in inspector.get_table_names(schema): + for table in self._get_table_names(inspector, schema): dataset_name = self.get_identifier( schema=schema, entity=table, inspector=inspector ) @@ -1226,6 +1226,12 @@ def loop_views( exc=e, ) + def _get_table_names(self, inspector: Inspector, schema: str) -> List[str]: + """Names of the tables loop_tables ingests and loop_profiler_requests + profiles. Override to drop table-like objects the dialect lists but the + source should skip (e.g. partitions of a partitioned table).""" + return inspector.get_table_names(schema) + def _get_view_names(self, inspector: Inspector, schema: str) -> List[str]: """Names of the views loop_views ingests. Override to add view-like objects the dialect lists separately (e.g. materialized views).""" @@ -1492,7 +1498,7 @@ def loop_profiler_requests( except NotImplementedError: logger.debug("Source does not support generating profile candidates.") - for table in inspector.get_table_names(schema): + for table in self._get_table_names(inspector, schema): dataset_name = self.get_identifier( schema=schema, entity=table, inspector=inspector ) diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/sql_report.py b/metadata-ingestion/src/datahub/ingestion/source/sql/sql_report.py index d3d114cc9a3d..f21290e54c8a 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/sql_report.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/sql_report.py @@ -98,6 +98,11 @@ class SQLSourceReport( default_factory=LossyList ) + # Postgres: partitions of declaratively partitioned tables skipped because + # include_table_partitions is disabled. The parent table is still ingested. + num_table_partitions_skipped: int = 0 + table_partitions_skipped: LossyList[str] = field(default_factory=LossyList) + def report_entity_scanned(self, name: str, ent_type: str = "table") -> None: """ Entity could be a view or a table diff --git a/metadata-ingestion/tests/integration/postgres/postgres_all_db_with_db_golden.json b/metadata-ingestion/tests/integration/postgres/postgres_all_db_with_db_golden.json index 5181382c100b..50a1b818c202 100644 --- a/metadata-ingestion/tests/integration/postgres/postgres_all_db_with_db_golden.json +++ b/metadata-ingestion/tests/integration/postgres/postgres_all_db_with_db_golden.json @@ -285,6 +285,847 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:a6097853edba03be190d99ece4b307ff" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "containerProperties", + "aspect": { + "json": { + "customProperties": { + "platform": "postgres", + "env": "PROD", + "database": "postgrestest", + "schema": "partitioned" + }, + "name": "partitioned", + "env": "PROD" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "dataPlatformInstance", + "aspect": { + "json": { + "platform": "urn:li:dataPlatform:postgres" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Schema" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "events_2022_02", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.events_2022_02", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + }, + { + "fieldPath": "created_at", + "nullable": false, + "type": { + "type": { + "com.linkedin.schema.DateType": {} + } + }, + "nativeDataType": "DATE", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "events", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.events", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + }, + { + "fieldPath": "created_at", + "nullable": false, + "type": { + "type": { + "com.linkedin.schema.DateType": {} + } + }, + "nativeDataType": "DATE", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "events_2022_03", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.events_2022_03", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + }, + { + "fieldPath": "created_at", + "nullable": false, + "type": { + "type": { + "com.linkedin.schema.DateType": {} + } + }, + "nativeDataType": "DATE", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "logs_child", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.logs_child", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "logs", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.logs", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "container", "entityUrn": "urn:li:container:51904fc8cd5cc729bc630decff284525", @@ -2346,6 +3187,171 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 2, + "fieldProfiles": [ + { + "fieldPath": "id", + "uniqueCount": 0, + "nullCount": 0 + }, + { + "fieldPath": "created_at", + "uniqueCount": 0, + "nullCount": 0 + } + ], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 2, + "fieldProfiles": [ + { + "fieldPath": "id", + "uniqueCount": 0, + "nullCount": 0 + }, + { + "fieldPath": "created_at", + "uniqueCount": 0, + "nullCount": 0 + } + ], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 2, + "fieldProfiles": [ + { + "fieldPath": "id", + "uniqueCount": 0, + "nullCount": 0 + }, + { + "fieldPath": "created_at", + "uniqueCount": 0, + "nullCount": 0 + } + ], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 1, + "fieldProfiles": [ + { + "fieldPath": "id", + "uniqueCount": 0, + "nullCount": 0 + } + ], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 1, + "fieldProfiles": [ + { + "fieldPath": "id", + "uniqueCount": 0, + "nullCount": 0 + } + ], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.public.metadata_aspect_v2,PROD)", @@ -2612,6 +3618,86 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.public.metadata_aspect_v2,PROD)", diff --git a/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_golden.json b/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_golden.json new file mode 100644 index 000000000000..676ffc7efe4f --- /dev/null +++ b/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_golden.json @@ -0,0 +1,629 @@ +[ +{ + "entityType": "container", + "entityUrn": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "changeType": "UPSERT", + "aspectName": "containerProperties", + "aspect": { + "json": { + "customProperties": { + "platform": "postgres", + "env": "PROD", + "database": "postgrestest" + }, + "name": "postgrestest", + "env": "PROD" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "changeType": "UPSERT", + "aspectName": "dataPlatformInstance", + "aspect": { + "json": { + "platform": "urn:li:dataPlatform:postgres" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Database" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:a6097853edba03be190d99ece4b307ff" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "containerProperties", + "aspect": { + "json": { + "customProperties": { + "platform": "postgres", + "env": "PROD", + "database": "postgrestest", + "schema": "partitioned" + }, + "name": "partitioned", + "env": "PROD" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "dataPlatformInstance", + "aspect": { + "json": { + "platform": "urn:li:dataPlatform:postgres" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Schema" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "events", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.events", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + }, + { + "fieldPath": "created_at", + "nullable": false, + "type": { + "type": { + "com.linkedin.schema.DateType": {} + } + }, + "nativeDataType": "DATE", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "logs_child", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.logs_child", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "logs", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.logs", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +} +] \ No newline at end of file diff --git a/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_to_file.yml b/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_to_file.yml new file mode 100644 index 000000000000..e352e46c623a --- /dev/null +++ b/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_to_file.yml @@ -0,0 +1,17 @@ +run_id: postgres-test + +source: + type: postgres + config: + host_port: 'localhost:5432' + database: 'postgrestest' + username: 'postgres' + password: 'example' + schema_pattern: + allow: + - 'partitioned' + include_table_partitions: false +sink: + type: file + config: + filename: "./postgres_skip_table_partitions_mces.json" diff --git a/metadata-ingestion/tests/integration/postgres/postgres_with_db_golden.json b/metadata-ingestion/tests/integration/postgres/postgres_with_db_golden.json index 03b223e943f4..35ee47793761 100644 --- a/metadata-ingestion/tests/integration/postgres/postgres_with_db_golden.json +++ b/metadata-ingestion/tests/integration/postgres/postgres_with_db_golden.json @@ -87,6 +87,847 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:a6097853edba03be190d99ece4b307ff" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "containerProperties", + "aspect": { + "json": { + "customProperties": { + "platform": "postgres", + "env": "PROD", + "database": "postgrestest", + "schema": "partitioned" + }, + "name": "partitioned", + "env": "PROD" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "dataPlatformInstance", + "aspect": { + "json": { + "platform": "urn:li:dataPlatform:postgres" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Schema" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "container", + "entityUrn": "urn:li:container:10576b964a216403b9353b41026355fa", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "events_2022_02", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.events_2022_02", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + }, + { + "fieldPath": "created_at", + "nullable": false, + "type": { + "type": { + "com.linkedin.schema.DateType": {} + } + }, + "nativeDataType": "DATE", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "events", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.events", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + }, + { + "fieldPath": "created_at", + "nullable": false, + "type": { + "type": { + "com.linkedin.schema.DateType": {} + } + }, + "nativeDataType": "DATE", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "events_2022_03", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.events_2022_03", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + }, + { + "fieldPath": "created_at", + "nullable": false, + "type": { + "type": { + "com.linkedin.schema.DateType": {} + } + }, + "nativeDataType": "DATE", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "logs_child", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.logs_child", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "logs", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.logs", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "container", "entityUrn": "urn:li:container:51904fc8cd5cc729bc630decff284525", @@ -2148,6 +2989,126 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 2, + "fieldProfiles": [], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 2, + "fieldProfiles": [], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 2, + "fieldProfiles": [], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 1, + "fieldProfiles": [], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 1, + "fieldProfiles": [], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.public.metadata_aspect_v2,PROD)", @@ -2244,6 +3205,86 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_02,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.public.metadata_aspect_v2,PROD)", diff --git a/metadata-ingestion/tests/integration/postgres/setup/setup.sql b/metadata-ingestion/tests/integration/postgres/setup/setup.sql index 319f8d20d21a..49cf35f49a91 100644 --- a/metadata-ingestion/tests/integration/postgres/setup/setup.sql +++ b/metadata-ingestion/tests/integration/postgres/setup/setup.sql @@ -117,3 +117,29 @@ CREATE TABLE special_types ( -- of -1. Scoped to this table: raw_orders/processed_orders were created after -- the ANALYZE above and intentionally cover the never-analyzed (-1) branch. ANALYZE special_types; + +-- Declarative partitioning: each partition is listed as its own table unless +-- include_table_partitions is false. logs_child uses table inheritance, which is +-- not partitioning, so it is ingested either way. +CREATE SCHEMA partitioned; + +CREATE TABLE partitioned.events ( + id INT, + created_at DATE NOT NULL +) PARTITION BY RANGE (created_at); + +CREATE TABLE partitioned.events_2022_02 PARTITION OF partitioned.events + FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'); + +CREATE TABLE partitioned.events_2022_03 PARTITION OF partitioned.events + FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'); + +CREATE TABLE partitioned.logs (id INT); + +CREATE TABLE partitioned.logs_child () INHERITS (partitioned.logs); + +-- Keep the new tables off the never-analyzed (-1) row-count branch, which +-- raw_orders/processed_orders already cover. +ANALYZE partitioned.events; +ANALYZE partitioned.logs; +ANALYZE partitioned.logs_child; diff --git a/metadata-ingestion/tests/integration/postgres/test_postgres.py b/metadata-ingestion/tests/integration/postgres/test_postgres.py index 5fed93895f24..fff0822fe7e5 100644 --- a/metadata-ingestion/tests/integration/postgres/test_postgres.py +++ b/metadata-ingestion/tests/integration/postgres/test_postgres.py @@ -87,6 +87,25 @@ def test_postgres_ingest_with_all_db( ) +@time_machine.travel(FROZEN_TIME, tick=False) +@pytest.mark.integration +def test_postgres_ingest_skip_table_partitions( + postgres_runner, pytestconfig, test_resources_dir, tmp_path +): + config_file = ( + test_resources_dir / "postgres_skip_table_partitions_to_file.yml" + ).resolve() + + run_datahub_cmd(["ingest", "-c", f"{config_file}"], tmp_path=tmp_path) + + mce_helpers.check_golden_file( + pytestconfig, + fail_on_output_mces=True, + output_path=tmp_path / "postgres_skip_table_partitions_mces.json", + golden_path=test_resources_dir / "postgres_skip_table_partitions_golden.json", + ) + + @time_machine.travel(FROZEN_TIME, tick=False) @pytest.mark.integration def test_postgres_test_connection( diff --git a/metadata-ingestion/tests/unit/test_postgres_source.py b/metadata-ingestion/tests/unit/test_postgres_source.py index 71914949d26e..68c9bb811719 100644 --- a/metadata-ingestion/tests/unit/test_postgres_source.py +++ b/metadata-ingestion/tests/unit/test_postgres_source.py @@ -223,6 +223,76 @@ def test_view_names_survive_materialized_view_listing_failure(): assert source.report.warnings +def _partitioned_inspector(partition_rows: Any) -> MagicMock: + inspector = MagicMock() + inspector.get_table_names.return_value = [ + "customers", + "events", + "events_2026_10", + "events_2026_11", + ] + inspector.engine.connect.return_value = FakeConnection( + {"relispartition": partition_rows} + ) + return inspector + + +def test_table_names_include_partitions_by_default(): + source = PostgresSource( + PostgresConfig.model_validate({**_base_config(), "database": "db"}), + PipelineContext(run_id="test"), + ) + inspector = _partitioned_inspector([]) + + assert len(source._get_table_names(inspector, "public")) == 4 + inspector.engine.connect.assert_not_called() + + +def test_table_names_skip_partitions_when_disabled(): + source = PostgresSource( + PostgresConfig.model_validate( + {**_base_config(), "database": "db", "include_table_partitions": False} + ), + PipelineContext(run_id="test"), + ) + inspector = _partitioned_inspector( + lambda params: ( + [ + SimpleNamespace(table_name="events_2026_10"), + SimpleNamespace(table_name="events_2026_11"), + ] + if params == {"schema": "public"} + else [] + ) + ) + + # loop_tables and loop_profiler_requests both list tables; count each once. + for _ in range(2): + assert source._get_table_names(inspector, "public") == ["customers", "events"] + + assert source.report.num_table_partitions_skipped == 2 + assert list(source.report.table_partitions_skipped) == [ + "db.public.events_2026_10", + "db.public.events_2026_11", + ] + + +def test_table_names_keep_partitions_when_listing_them_fails(): + source = PostgresSource( + PostgresConfig.model_validate( + {**_base_config(), "database": "db", "include_table_partitions": False} + ), + PipelineContext(run_id="test"), + ) + inspector = _partitioned_inspector( + RuntimeError('column "relispartition" does not exist') + ) + + assert len(source._get_table_names(inspector, "public")) == 4 + assert source.report.num_table_partitions_skipped == 0 + assert source.report.warnings + + def test_database_in_identifier(): config = PostgresConfig.model_validate({**_base_config(), "database": "postgres"}) mock_inspector = mock.MagicMock() From 5f14d9d1f47861e312e93b47e8afdfecaebf0894 Mon Sep 17 00:00:00 2001 From: "neha.marne" Date: Thu, 26 Nov 2026 16:02:09 +0530 Subject: [PATCH 02/10] test(ingest/postgres): cover profiling when table partitions are skipped Enable table-level profiling in the skip-partitions integration recipe so the profiler's table listing is exercised with include_table_partitions disabled. The golden now shows datasetProfile only for the kept tables. Also: - include the database in the partition-listing warning context - document that stateful ingestion soft-deletes previously ingested partitions, and how CockroachDB and TimescaleDB are affected - make the report field comment source-agnostic - trim the get_table_partitions docstring Co-Authored-By: Claude Opus 5.5 --- .../docs/sources/postgres/postgres_post.md | 4 + .../ingestion/source/sql/postgres/query.py | 2 +- .../ingestion/source/sql/postgres/source.py | 2 +- .../ingestion/source/sql/sql_report.py | 4 +- ...postgres_skip_table_partitions_golden.json | 117 ++++++++++++++++++ ...postgres_skip_table_partitions_to_file.yml | 5 + 6 files changed, 130 insertions(+), 4 deletions(-) diff --git a/metadata-ingestion/docs/sources/postgres/postgres_post.md b/metadata-ingestion/docs/sources/postgres/postgres_post.md index ee705e850ff5..067c7b5b499f 100644 --- a/metadata-ingestion/docs/sources/postgres/postgres_post.md +++ b/metadata-ingestion/docs/sources/postgres/postgres_post.md @@ -202,6 +202,10 @@ Partitions are detected through `pg_class.relispartition`, so new partitions are Child tables created with table inheritance (`INHERITS`) are not partitions and are always ingested. Use `table_pattern` to exclude them. +If stateful ingestion with `remove_stale_metadata` is enabled, turning this option off soft-deletes partitions that earlier runs ingested. + +The CockroachDB and TimescaleDB sources inherit this option. TimescaleDB hypertable chunks are inheritance children, not partitions, so they are still ingested. On CockroachDB, partition detection may fail; the source then logs a warning and ingests all tables. + ### Limitations Module behavior is constrained by source APIs, permissions, and metadata exposed by the platform. Refer to capability notes for unsupported or conditional features. diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py index 01e1af8adad0..29a6c60439f9 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py @@ -52,7 +52,7 @@ def get_table_partitions() -> TextClause: """List tables in a schema that are partitions of a partitioned table. relispartition was added in Postgres 10, alongside declarative - partitioning. Use with: connection.execute(query, {"schema": schema}) + partitioning. """ return text( """ diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py index 16f575b4f1c9..510c53b1ab52 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py @@ -774,7 +774,7 @@ def _get_table_names(self, inspector: Inspector, schema: str) -> List[str]: title="Failed to list table partitions", message="Partitions in this schema will be ingested as regular tables. " "Detecting partitions requires Postgres 10+ and read access to pg_catalog.", - context=schema, + context=f"{self.get_db_name(inspector)}.{schema}", exc=e, ) return table_names diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/sql_report.py b/metadata-ingestion/src/datahub/ingestion/source/sql/sql_report.py index f21290e54c8a..b98cfbbc1270 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/sql_report.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/sql_report.py @@ -98,8 +98,8 @@ class SQLSourceReport( default_factory=LossyList ) - # Postgres: partitions of declaratively partitioned tables skipped because - # include_table_partitions is disabled. The parent table is still ingested. + # Partitions dropped by a source's _get_table_names override (e.g. Postgres + # with include_table_partitions disabled). The parent table is still ingested. num_table_partitions_skipped: int = 0 table_partitions_skipped: LossyList[str] = field(default_factory=LossyList) diff --git a/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_golden.json b/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_golden.json index 676ffc7efe4f..d10818a023a5 100644 --- a/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_golden.json +++ b/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_golden.json @@ -625,5 +625,122 @@ "runId": "postgres-test", "lastRunId": "no-run-id-provided" } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 2, + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 1, + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 1, + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs_child,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } } ] \ No newline at end of file diff --git a/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_to_file.yml b/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_to_file.yml index e352e46c623a..49fb68930677 100644 --- a/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_to_file.yml +++ b/metadata-ingestion/tests/integration/postgres/postgres_skip_table_partitions_to_file.yml @@ -11,6 +11,11 @@ source: allow: - 'partitioned' include_table_partitions: false + # Profiling lists tables separately from loop_tables; partitions must be + # skipped there too, so only the kept tables get a datasetProfile. + profiling: + enabled: true + profile_table_level_only: true sink: type: file config: From e7b817c97c25a79d3b509e2b32c12e3c9b3952c8 Mon Sep 17 00:00:00 2001 From: "neha.marne" Date: Thu, 26 Nov 2026 18:18:09 +0530 Subject: [PATCH 03/10] refactor(ingest/postgres): list table partitions once per schema loop_tables and loop_profiler_requests both call _get_table_names, so the partition query ran twice per schema. If one call failed and the other succeeded, partitions could be profiled without being ingested, and the failure warning was reported twice. Cache the partition names per (database, schema) on first listing, including a failed listing as an empty set, so both passes agree. Report skipped partitions only on the first listing, which replaces the dedupe set. Type the test helper with Outcome instead of Any. Co-Authored-By: Claude Opus 5.5 --- .../ingestion/source/sql/postgres/source.py | 51 +++++++++++-------- .../tests/unit/test_postgres_source.py | 15 ++++-- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py index 510c53b1ab52..2cbcdfdbafd8 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py @@ -9,7 +9,6 @@ Iterable, List, Optional, - Set, Tuple, Type, Union, @@ -589,9 +588,11 @@ def __init__(self, config: PostgresConfig, ctx: PipelineContext): config.rds_iam_token_manager() ) - # loop_tables and loop_profiler_requests both list tables, so a skipped - # partition is seen twice per run; this keeps the report count exact. - self._skipped_table_partitions: Set[str] = set() + # Partition names per (database, schema). loop_tables and + # loop_profiler_requests both list tables, so caching the first answer + # keeps the two passes consistent (also when listing fails) and lets + # each schema be queried and reported once. + self._table_partitions: Dict[Tuple[str, str], FrozenSet[str]] = {} self.sql_aggregator: Optional[SqlParsingAggregator] = None if self.config.include_query_lineage: @@ -761,14 +762,36 @@ def _get_table_names(self, inspector: Inspector, schema: str) -> List[str]: table_names = super()._get_table_names(inspector, schema) if self.config.include_table_partitions: return table_names + + key = (self.get_db_name(inspector), schema) + first_listing = key not in self._table_partitions + if first_listing: + self._table_partitions[key] = self._list_table_partitions(inspector, schema) + partitions = self._table_partitions[key] + + kept: List[str] = [] + for table in table_names: + if table not in partitions: + kept.append(table) + elif first_listing: + dataset_name = self.get_identifier( + schema=schema, entity=table, inspector=inspector + ) + self.report.num_table_partitions_skipped += 1 + self.report.table_partitions_skipped.append(dataset_name) + return kept + + def _list_table_partitions( + self, inspector: Inspector, schema: str + ) -> FrozenSet[str]: try: with inspector.engine.connect() as conn: - partitions = { + return frozenset( row.table_name for row in conn.execute( PostgresQuery.get_table_partitions(), {"schema": schema} ) - } + ) except Exception as e: self.report.warning( title="Failed to list table partitions", @@ -777,21 +800,7 @@ def _get_table_names(self, inspector: Inspector, schema: str) -> List[str]: context=f"{self.get_db_name(inspector)}.{schema}", exc=e, ) - return table_names - - kept: List[str] = [] - for table in table_names: - if table not in partitions: - kept.append(table) - continue - dataset_name = self.get_identifier( - schema=schema, entity=table, inspector=inspector - ) - if dataset_name not in self._skipped_table_partitions: - self._skipped_table_partitions.add(dataset_name) - self.report.num_table_partitions_skipped += 1 - self.report.table_partitions_skipped.append(dataset_name) - return kept + return frozenset() def get_workunits_internal(self) -> Iterable[Union[MetadataWorkUnit, SqlWorkUnit]]: yield from super().get_workunits_internal() diff --git a/metadata-ingestion/tests/unit/test_postgres_source.py b/metadata-ingestion/tests/unit/test_postgres_source.py index 68c9bb811719..4589bf591694 100644 --- a/metadata-ingestion/tests/unit/test_postgres_source.py +++ b/metadata-ingestion/tests/unit/test_postgres_source.py @@ -58,7 +58,7 @@ ) from tests.test_helpers.masking_state_helpers import capture_masked_log from tests.unit.conftest import as_mock, log_contexts, single_aspect -from tests.unit.sql_test_helpers import FakeConnection, FakeResult +from tests.unit.sql_test_helpers import FakeConnection, FakeResult, Outcome def _base_config(): @@ -223,7 +223,7 @@ def test_view_names_survive_materialized_view_listing_failure(): assert source.report.warnings -def _partitioned_inspector(partition_rows: Any) -> MagicMock: +def _partitioned_inspector(partition_rows: Outcome) -> MagicMock: inspector = MagicMock() inspector.get_table_names.return_value = [ "customers", @@ -266,10 +266,12 @@ def test_table_names_skip_partitions_when_disabled(): ) ) - # loop_tables and loop_profiler_requests both list tables; count each once. + # loop_tables and loop_profiler_requests both list tables; query and count + # each schema once. for _ in range(2): assert source._get_table_names(inspector, "public") == ["customers", "events"] + inspector.engine.connect.assert_called_once() assert source.report.num_table_partitions_skipped == 2 assert list(source.report.table_partitions_skipped) == [ "db.public.events_2026_10", @@ -288,7 +290,12 @@ def test_table_names_keep_partitions_when_listing_them_fails(): RuntimeError('column "relispartition" does not exist') ) - assert len(source._get_table_names(inspector, "public")) == 4 + all_tables = ["customers", "events", "events_2026_10", "events_2026_11"] + # The failure is remembered, so profiling keeps the same tables ingestion did. + for _ in range(2): + assert source._get_table_names(inspector, "public") == all_tables + + inspector.engine.connect.assert_called_once() assert source.report.num_table_partitions_skipped == 0 assert source.report.warnings From a58e4354ee2633cf0882bcc1c697b581a38c92ee Mon Sep 17 00:00:00 2001 From: "neha.marne" Date: Fri, 27 Nov 2026 14:42:06 +0530 Subject: [PATCH 04/10] test(ingest/postgres): check partition cache is keyed by database and schema Add a unit test that lists two schemas in one database and one schema in a second database, twice each. It checks that each listing drops only its own partitions, that the partition query runs once per (database, schema), and that each skipped partition is reported once. Also say in the listing-failure warning that partitions are profiled as well as ingested, since the failed listing is reused by profiling. Co-Authored-By: Claude Opus 5.5 --- .../ingestion/source/sql/postgres/source.py | 2 +- .../tests/unit/test_postgres_source.py | 56 ++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py index 2cbcdfdbafd8..21098ff30b56 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py @@ -795,7 +795,7 @@ def _list_table_partitions( except Exception as e: self.report.warning( title="Failed to list table partitions", - message="Partitions in this schema will be ingested as regular tables. " + message="Partitions in this schema will be ingested and profiled as regular tables. " "Detecting partitions requires Postgres 10+ and read access to pg_catalog.", context=f"{self.get_db_name(inspector)}.{schema}", exc=e, diff --git a/metadata-ingestion/tests/unit/test_postgres_source.py b/metadata-ingestion/tests/unit/test_postgres_source.py index 4589bf591694..df7151d508fc 100644 --- a/metadata-ingestion/tests/unit/test_postgres_source.py +++ b/metadata-ingestion/tests/unit/test_postgres_source.py @@ -1,6 +1,6 @@ from io import StringIO from types import SimpleNamespace -from typing import Any, Dict, Iterator, List +from typing import Any, Dict, Iterator, List, Optional, Tuple from unittest import mock from unittest.mock import MagicMock, patch from urllib.parse import quote @@ -300,6 +300,60 @@ def test_table_names_keep_partitions_when_listing_them_fails(): assert source.report.warnings +def test_table_partitions_listed_per_database_and_schema(): + # No database set, so each inspector is its own database (multi-db ingestion). + source = PostgresSource( + PostgresConfig.model_validate( + {**_base_config(), "include_table_partitions": False} + ), + PipelineContext(run_id="test"), + ) + partitions_by_schema: Dict[str, Dict[str, List[str]]] = { + "db1": {"public": ["events_2026_10"], "other": ["events_2026_11"]}, + "db2": {"public": []}, + } + queried: List[Tuple[str, str]] = [] + + def inspector_for(db: str) -> MagicMock: + def partition_rows(params: Optional[Dict[str, Any]]) -> List[SimpleNamespace]: + assert params is not None + queried.append((db, params["schema"])) + return [ + SimpleNamespace(table_name=name) + for name in partitions_by_schema[db][params["schema"]] + ] + + inspector = _partitioned_inspector(partition_rows) + inspector.engine.url.database = db + return inspector + + db1, db2 = inspector_for("db1"), inspector_for("db2") + for _ in range(2): + assert source._get_table_names(db1, "public") == [ + "customers", + "events", + "events_2026_11", + ] + assert source._get_table_names(db1, "other") == [ + "customers", + "events", + "events_2026_10", + ] + assert source._get_table_names(db2, "public") == [ + "customers", + "events", + "events_2026_10", + "events_2026_11", + ] + + assert queried == [("db1", "public"), ("db1", "other"), ("db2", "public")] + assert source.report.num_table_partitions_skipped == 2 + assert list(source.report.table_partitions_skipped) == [ + "db1.public.events_2026_10", + "db1.other.events_2026_11", + ] + + def test_database_in_identifier(): config = PostgresConfig.model_validate({**_base_config(), "database": "postgres"}) mock_inspector = mock.MagicMock() From 7c10ae58d929341891f4a28b96e4cfccb3ae6e74 Mon Sep 17 00:00:00 2001 From: "neha.marne" Date: Fri, 27 Nov 2026 15:38:49 +0530 Subject: [PATCH 05/10] refactor(ingest/postgres): limit partition query to tables relispartition is also true for partitions of partitioned indexes. Those names never match a table, so results were already correct, but filtering on relkind IN ('r', 'p') keeps the set to the ordinary and partitioned tables that SQLAlchemy's get_table_names lists and makes the intent explicit. Sub-partitions (relkind 'p') are still skipped. Co-Authored-By: Claude Opus 5.5 --- .../src/datahub/ingestion/source/sql/postgres/query.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py index 29a6c60439f9..fd36c993e92e 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py @@ -52,7 +52,9 @@ def get_table_partitions() -> TextClause: """List tables in a schema that are partitions of a partitioned table. relispartition was added in Postgres 10, alongside declarative - partitioning. + partitioning. It is also set on partitions of partitioned indexes, so + relkind limits the result to the kinds SQLAlchemy's get_table_names + lists: ordinary (r) and partitioned (p, i.e. sub-partitions) tables. """ return text( """ @@ -61,6 +63,7 @@ def get_table_partitions() -> TextClause: JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = :schema AND c.relispartition + AND c.relkind IN ('r', 'p') """ ) From 6ba03889004b066d9351691fa0d07bde2cc5beed Mon Sep 17 00:00:00 2001 From: "neha.marne" Date: Fri, 27 Nov 2026 15:47:47 +0530 Subject: [PATCH 06/10] fix(ingest/postgres): point partition-listing warning at the likely cause Every role can read pg_class by default, so the hint about read access to pg_catalog rarely applied. Say that pg_class.relispartition could not be read and that it needs Postgres 10+; the underlying error is already attached via exc. Co-Authored-By: Claude Opus 5.5 --- .../src/datahub/ingestion/source/sql/postgres/source.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py index 21098ff30b56..5fe9ef1e7bfa 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py @@ -796,7 +796,7 @@ def _list_table_partitions( self.report.warning( title="Failed to list table partitions", message="Partitions in this schema will be ingested and profiled as regular tables. " - "Detecting partitions requires Postgres 10+ and read access to pg_catalog.", + "Could not read pg_class.relispartition (needs Postgres 10+).", context=f"{self.get_db_name(inspector)}.{schema}", exc=e, ) From 83f6ff79c18c0498b523aaf185500fe349b616db Mon Sep 17 00:00:00 2001 From: "neha.marne" Date: Fri, 27 Nov 2026 15:51:26 +0530 Subject: [PATCH 07/10] test(ingest/postgres): assert exact table list in default partitions test Compare the full list instead of its length, as the other partition tests do, so a wrong table returned in place of a dropped one fails. Co-Authored-By: Claude Opus 5.5 --- metadata-ingestion/tests/unit/test_postgres_source.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/metadata-ingestion/tests/unit/test_postgres_source.py b/metadata-ingestion/tests/unit/test_postgres_source.py index df7151d508fc..5897137d5c06 100644 --- a/metadata-ingestion/tests/unit/test_postgres_source.py +++ b/metadata-ingestion/tests/unit/test_postgres_source.py @@ -244,7 +244,12 @@ def test_table_names_include_partitions_by_default(): ) inspector = _partitioned_inspector([]) - assert len(source._get_table_names(inspector, "public")) == 4 + assert source._get_table_names(inspector, "public") == [ + "customers", + "events", + "events_2026_10", + "events_2026_11", + ] inspector.engine.connect.assert_not_called() From 408d62e3be45df8505dcfcc9be3aa89126513c8f Mon Sep 17 00:00:00 2001 From: "neha.marne" Date: Fri, 27 Nov 2026 16:55:27 +0530 Subject: [PATCH 08/10] test(ingest/postgres): cover sub-partitions in partition integration tests Make partitioned.events_2022_03 itself partitioned (PARTITION BY LIST) with a DEFAULT child, events_2022_03_default. The default goldens now include the sub-partition, and the skip-partitions golden is unchanged, which shows sub-partitions are skipped along with direct partitions. Co-Authored-By: Claude Opus 5.5 --- .../postgres_all_db_with_db_golden.json | 202 ++++++++++++++++++ .../postgres/postgres_with_db_golden.json | 191 +++++++++++++++++ .../integration/postgres/setup/setup.sql | 11 +- 3 files changed, 401 insertions(+), 3 deletions(-) diff --git a/metadata-ingestion/tests/integration/postgres/postgres_all_db_with_db_golden.json b/metadata-ingestion/tests/integration/postgres/postgres_all_db_with_db_golden.json index 50a1b818c202..8c9f3bdcaf1b 100644 --- a/metadata-ingestion/tests/integration/postgres/postgres_all_db_with_db_golden.json +++ b/metadata-ingestion/tests/integration/postgres/postgres_all_db_with_db_golden.json @@ -697,6 +697,157 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "events_2022_03_default", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.events_2022_03_default", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + }, + { + "fieldPath": "created_at", + "nullable": false, + "type": { + "type": { + "com.linkedin.schema.DateType": {} + } + }, + "nativeDataType": "DATE", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", @@ -3257,6 +3408,41 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 2, + "fieldProfiles": [ + { + "fieldPath": "id", + "uniqueCount": 0, + "nullCount": 0 + }, + { + "fieldPath": "created_at", + "uniqueCount": 0, + "nullCount": 0 + } + ], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", @@ -3666,6 +3852,22 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", diff --git a/metadata-ingestion/tests/integration/postgres/postgres_with_db_golden.json b/metadata-ingestion/tests/integration/postgres/postgres_with_db_golden.json index 35ee47793761..f55425c4f625 100644 --- a/metadata-ingestion/tests/integration/postgres/postgres_with_db_golden.json +++ b/metadata-ingestion/tests/integration/postgres/postgres_with_db_golden.json @@ -499,6 +499,157 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "container", + "aspect": { + "json": { + "container": "urn:li:container:10576b964a216403b9353b41026355fa" + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProperties", + "aspect": { + "json": { + "customProperties": {}, + "name": "events_2022_03_default", + "tags": [] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "schemaMetadata", + "aspect": { + "json": { + "schemaName": "postgrestest.partitioned.events_2022_03_default", + "platform": "urn:li:dataPlatform:postgres", + "version": 0, + "created": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "lastModified": { + "time": 0, + "actor": "urn:li:corpuser:unknown" + }, + "hash": "", + "platformSchema": { + "com.linkedin.schema.MySqlDDL": { + "tableSchema": "" + } + }, + "fields": [ + { + "fieldPath": "id", + "nullable": true, + "type": { + "type": { + "com.linkedin.schema.NumberType": {} + } + }, + "nativeDataType": "INTEGER", + "recursive": false, + "isPartOfKey": false + }, + { + "fieldPath": "created_at", + "nullable": false, + "type": { + "type": { + "com.linkedin.schema.DateType": {} + } + }, + "nativeDataType": "DATE", + "recursive": false, + "isPartOfKey": false + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "subTypes", + "aspect": { + "json": { + "typeNames": [ + "Table" + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "browsePathsV2", + "aspect": { + "json": { + "path": [ + { + "id": "urn:li:container:a6097853edba03be190d99ece4b307ff", + "urn": "urn:li:container:a6097853edba03be190d99ece4b307ff" + }, + { + "id": "urn:li:container:10576b964a216403b9353b41026355fa", + "urn": "urn:li:container:10576b964a216403b9353b41026355fa" + } + ] + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", @@ -3037,6 +3188,30 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "datasetProfile", + "aspect": { + "json": { + "timestampMillis": 1646575200000, + "partitionSpec": { + "partition": "FULL_TABLE_SNAPSHOT", + "type": "FULL_TABLE" + }, + "rowCount": 0, + "columnCount": 2, + "fieldProfiles": [], + "sizeInBytes": 0 + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03,PROD)", @@ -3253,6 +3428,22 @@ "lastRunId": "no-run-id-provided" } }, +{ + "entityType": "dataset", + "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.events_2022_03_default,PROD)", + "changeType": "UPSERT", + "aspectName": "status", + "aspect": { + "json": { + "removed": false + } + }, + "systemMetadata": { + "lastObserved": 1646575200000, + "runId": "postgres-test", + "lastRunId": "no-run-id-provided" + } +}, { "entityType": "dataset", "entityUrn": "urn:li:dataset:(urn:li:dataPlatform:postgres,postgrestest.partitioned.logs,PROD)", diff --git a/metadata-ingestion/tests/integration/postgres/setup/setup.sql b/metadata-ingestion/tests/integration/postgres/setup/setup.sql index 49cf35f49a91..d1b00ef7ff6c 100644 --- a/metadata-ingestion/tests/integration/postgres/setup/setup.sql +++ b/metadata-ingestion/tests/integration/postgres/setup/setup.sql @@ -119,8 +119,9 @@ CREATE TABLE special_types ( ANALYZE special_types; -- Declarative partitioning: each partition is listed as its own table unless --- include_table_partitions is false. logs_child uses table inheritance, which is --- not partitioning, so it is ingested either way. +-- include_table_partitions is false. events_2022_03 is itself partitioned, so +-- events_2022_03_default is a sub-partition and is skipped too. logs_child uses +-- table inheritance, which is not partitioning, so it is ingested either way. CREATE SCHEMA partitioned; CREATE TABLE partitioned.events ( @@ -132,7 +133,11 @@ CREATE TABLE partitioned.events_2022_02 PARTITION OF partitioned.events FOR VALUES FROM ('2022-02-01') TO ('2022-03-01'); CREATE TABLE partitioned.events_2022_03 PARTITION OF partitioned.events - FOR VALUES FROM ('2022-03-01') TO ('2022-04-01'); + FOR VALUES FROM ('2022-03-01') TO ('2022-04-01') + PARTITION BY LIST (id); + +CREATE TABLE partitioned.events_2022_03_default + PARTITION OF partitioned.events_2022_03 DEFAULT; CREATE TABLE partitioned.logs (id INT); From 006211a7fe2ea2db381de7edb89bdd9f2bd0340a Mon Sep 17 00:00:00 2001 From: "neha.marne" Date: Fri, 27 Nov 2026 16:58:44 +0530 Subject: [PATCH 09/10] refactor(ingest/postgres): shorten partition cache comment Keep only the reason for the cache: loop_tables and loop_profiler_requests must skip the same tables, including after a failed listing. Co-Authored-By: Claude Opus 5.5 --- .../src/datahub/ingestion/source/sql/postgres/source.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py index 5fe9ef1e7bfa..c48c141696cf 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/source.py @@ -588,10 +588,8 @@ def __init__(self, config: PostgresConfig, ctx: PipelineContext): config.rds_iam_token_manager() ) - # Partition names per (database, schema). loop_tables and - # loop_profiler_requests both list tables, so caching the first answer - # keeps the two passes consistent (also when listing fails) and lets - # each schema be queried and reported once. + # Cached so loop_tables and loop_profiler_requests skip the same tables, + # including after a listing failure. self._table_partitions: Dict[Tuple[str, str], FrozenSet[str]] = {} self.sql_aggregator: Optional[SqlParsingAggregator] = None From 3712d4355f239efe9397a5dde3065fa2f4ce91a7 Mon Sep 17 00:00:00 2001 From: "neha.marne" Date: Fri, 27 Nov 2026 17:06:37 +0530 Subject: [PATCH 10/10] docs(ingest/postgres): clarify relkind p in partition query docstring A relkind 'p' row that is also a partition is an intermediate partitioned table, not a leaf sub-partition; leaf partitions at any level are 'r'. Co-Authored-By: Claude Opus 5.5 --- .../src/datahub/ingestion/source/sql/postgres/query.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py index fd36c993e92e..915737d3b041 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py +++ b/metadata-ingestion/src/datahub/ingestion/source/sql/postgres/query.py @@ -54,7 +54,8 @@ def get_table_partitions() -> TextClause: relispartition was added in Postgres 10, alongside declarative partitioning. It is also set on partitions of partitioned indexes, so relkind limits the result to the kinds SQLAlchemy's get_table_names - lists: ordinary (r) and partitioned (p, i.e. sub-partitions) tables. + lists: ordinary (r) and partitioned (p) tables. A p row here is a + partition that has its own partitions. """ return text( """