Lineage from Snowflake
An AWS Glue crawler can collect lineage from Snowflake and add it to your lineage graph. The crawler reads Snowflake query and access history, converts statements that move data into OpenLineage events, and sends them to AWS Glue Data Catalog.
What's captured
The crawler captures the following:
-
Successful statements that create or change data:
CREATE,ALTER,CREATE OR ALTER,DROP,CREATE TABLE AS SELECT,COPY,INSERT, andUNLOAD. -
The fully qualified tables involved (database, schema, and table) and their type.
-
The user who ran the statement, the query ID, the start and end time, and the query text.
-
The current schema of the tables involved.
Not captured
The crawler doesn't capture the following:
-
Lineage from Python, Java, or Scala code in notebooks or stored procedures.
-
Temporary tables.
Prerequisites
To collect lineage from Snowflake, you need the following:
-
Snowflake Enterprise Edition or higher, which provides access history.
-
A Snowflake role that can read the
SNOWFLAKE.ACCOUNT_USAGEviews, for example throughIMPORTED PRIVILEGESon theSNOWFLAKEdatabase, and a warehouse to run queries. -
An AWS Glue Snowflake connection.
Set up lineage collection
To set up lineage collection, do the following:
-
Create an AWS Glue connection of type
SNOWFLAKE. -
Create a crawler on the connection with lineage collection turned on, and set a schedule. Hourly is recommended.
-
Give the crawler's IAM role
glue:PostLineageEventand access to the connection secret.
How collection works
Lineage collection works as follows:
-
First run. Collects the last 7 days of lineage.
-
Later runs. Collect new statements since the previous run, with an overlap of about 3 hours, because Snowflake access history can be up to 3 hours late.
-
The crawler collects lineage only for databases that the connection can access.