Data lineage analysis

Updated at:
Copy as MD

AnalyticDB for PostgreSQL supports asynchronous parsing of data processing SQL statements from database audit logs to generate table-level and column-level lineage relationships. You can view upstream and downstream dependencies in DataWorks Data Map.

Usage notes

  • Data lineage analysis performs static parsing based on SQL text in audit logs. It does not parse actual execution plans or verify whether SQL statements are executed successfully, transactions are committed, or data is actually written. Lineage results cannot be used as a basis for determining SQL execution status, execution frequency, or data consistency.

  • This topic uses an allowlist approach. Only the SQL patterns explicitly listed in this topic are supported. Unlisted syntax, object types, and combinations are not supported.

  • After this feature is enabled, background processes continuously read and parse audit logs, which increases the CPU and memory usage of the coordinator node. The busier the workload, the faster audit logs are generated, and the higher the resource consumption. To disable this feature, submit a ticket.

  • When you use Data Map in DataWorks, the data lineage analysis feature of AnalyticDB for PostgreSQL is automatically enabled without manual intervention.

Prerequisites

Before you use data lineage analysis, make sure that the following conditions are met:

  • The instance runs AnalyticDB for PostgreSQL 6.0 in the public cloud, and the kernel version is 6.3.11.1 or later. AnalyticDB for PostgreSQL 7.0 instances do not support this feature.

  • The instance is not in Serverless mode.

  • The instance is deployed in the public cloud.

Supported SQL statements

Data lineage analysis supports only data processing SQL statements that contain explicit source and destination tables with simple and clear column mappings. The following three types of statements are supported:

SQL type

Supported syntax

Table-level lineage

Column-level lineage

CREATE TABLE AS SELECT

CREATE TABLE ... AS SELECT ... FROM ...

Supported

Supported

SELECT INTO

SELECT ... INTO ... FROM ...

Supported

Supported

INSERT INTO SELECT

INSERT INTO ... (...) SELECT ... FROM ...

Supported

Supported

The preceding SQL statements must also meet all of the following conditions:

  • A single SQL statement contains only one source table and one destination table.

  • Table names and column names use lowercase identifiers without double quotation marks.

  • The SELECT list must explicitly specify columns. SELECT * and table_name.* are not supported.

  • Source and destination columns must be in one-to-one correspondence by order.

  • Each destination column can only be derived directly from one source column. Functions, operations, constants, and other expressions are not supported.

  • INSERT INTO SELECT must explicitly specify the destination column list, and the number of destination columns must match the number of SELECT columns.

  • The SQL statement must not contain any structures listed in the "Unsupported SQL and query structures" section of this topic.

Supported examples

CREATE TABLE AS SELECT

CREATE TABLE target_table AS
SELECT id, name
FROM source_table;

Generated lineage:

  • Table-level: source_table → target_table

  • Column-level: source_table.id → target_table.id

  • Column-level: source_table.name → target_table.name

SELECT INTO

SELECT id, name
INTO target_table
FROM source_table;

Generated lineage:

  • Table-level: source_table → target_table

  • Column-level: source_table.id → target_table.id

  • Column-level: source_table.name → target_table.name

INSERT INTO SELECT

INSERT INTO target_table (id, name)
SELECT id, name
FROM source_table;

Generated lineage:

  • Table-level: source_table → target_table

  • Column-level: source_table.id → target_table.id

  • Column-level: source_table.name → target_table.name

Unsupported SQL and query structures

If a SQL statement contains any of the following syntax, objects, or scenarios, the entire statement is not supported. Even if the system occasionally generates partial lineage, the results are not guaranteed to be correct or complete.

Type

Unsupported scope or examples

General queries

SELECT without INTO, such as SELECT id FROM sourcetable;

UPDATE

All UPDATE statements, including those with subqueries, row-assignment subqueries, and UPDATE ... FROM

Other DML

INSERT ... VALUES, INSERT ... DEFAULT VALUES, DELETE, MERGE

Multi-table queries

JOIN, comma-separated joins, multi-source queries, self-joins

Subqueries

FROM subqueries, WHERE subqueries, scalar subqueries, correlated subqueries, and nested subqueries

CTE

WITH, recursive CTEs

Set operations

UNION, UNION ALL, INTERSECT, EXCEPT

Aggregation and grouping

Aggregate functions, GROUP BY, HAVING

Sorting and result modifiers

DISTINCT, ORDER BY, LIMIT, OFFSET, window functions

Conditional filtering

WHERE clause

Column expressions

Function calls, arithmetic operations, string concatenation, CASE, type casting, array or row expressions

Indirect column mapping

Constants, one source column mapped to multiple destination columns, multiple source columns computed into one destination column

Unspecified destination columns

INSERT INTO targettable SELECT ...

DDL and administration statements

CREATE TABLE without a query clause, CREATE TABLE LIKE, ALTER, DROP, TRUNCATE, COMMENT, GRANT

Views

CREATE VIEW, CREATE MATERIALIZED VIEW, and SQL using views or materialized views as source or destination

Special table types

Temporary tables, partitioned tables, foreign tables, and other non-standard persistent tables

Cross-schema or cross-database

Non-public schemas, cross-schema or cross-database references

Special identifiers

Double-quoted identifiers, case-sensitive names, or object names that cannot be uniquely restored

External data I/O

COPY, external loading, external export, and lineage between external media such as files or OSS and tables

Procedural or dynamic SQL

Stored procedures, UDFs, DO blocks, dynamic SQL, PREPARE, EXECUTE

Explain execution

EXPLAIN, EXPLAIN ANALYZE

Complex input

Multiple SQL statements submitted at once, or SQL truncated or incompletely recoverable in audit logs

Additional limits

  • Asynchronous display: Lineage is asynchronously parsed and reported by background processes. Real-time generation is not guaranteed. After a SQL statement is executed, the lineage display in DataWorks Data Map may be delayed.

  • Execution result not evaluated: The parser does not determine whether a SQL statement is executed successfully or whether a transaction is committed. SQL statements that fail or are rolled back may still generate lineage, which may be inconsistent with the actual data write results.

  • Implicit relationships not inferred: The system only parses source tables, destination tables, and column mappings that are directly present in the SQL text. It does not infer partition parent-child relationships, view expansion relationships, function-internal relationships, or procedure-internal relationships.

  • No real-time or completeness SLA: Lineage results are used to assist impact analysis and data understanding. They should not be used as the sole basis for auditing, billing, task status determination, or data consistency verification.