Data lineage analysis
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 |
|
|
Supported |
Supported |
|
|
Supported |
Supported |
|
|
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
SELECTlist must explicitly specify columns.SELECT *andtable_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 SELECTmust explicitly specify the destination column list, and the number of destination columns must match the number ofSELECTcolumns.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_tableColumn-level:
source_table.id→target_table.idColumn-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_tableColumn-level:
source_table.id→target_table.idColumn-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_tableColumn-level:
source_table.id→target_table.idColumn-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 |
|
|
All |
Other DML |
|
Multi-table queries |
|
Subqueries |
|
CTE |
|
Set operations |
|
Aggregation and grouping |
Aggregate functions, |
Sorting and result modifiers |
|
Conditional filtering |
|
Column expressions |
Function calls, arithmetic operations, string concatenation, |
Indirect column mapping |
Constants, one source column mapped to multiple destination columns, multiple source columns computed into one destination column |
Unspecified destination columns |
|
DDL and administration statements |
|
Views |
|
Special table types |
Temporary tables, partitioned tables, foreign tables, and other non-standard persistent tables |
Cross-schema or cross-database |
Non- |
Special identifiers |
Double-quoted identifiers, case-sensitive names, or object names that cannot be uniquely restored |
External data I/O |
|
Procedural or dynamic SQL |
Stored procedures, UDFs, |
Explain execution |
|
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.