View a markdown version of this page

Lineage from Snowflake - AWS Glue

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, and UNLOAD.

  • 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_USAGE views, for example through IMPORTED PRIVILEGES on the SNOWFLAKE database, and a warehouse to run queries.

  • An AWS Glue Snowflake connection.

Set up lineage collection

To set up lineage collection, do the following:

  1. Create an AWS Glue connection of type SNOWFLAKE.

  2. Create a crawler on the connection with lineage collection turned on, and set a schedule. Hourly is recommended.

  3. Give the crawler's IAM role glue:PostLineageEvent and 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.