Area: Ingestion Issues
Sub-Area: Snowflake Connector, View Metadata & Lineage
Applies to: OSS + Cloud
Issue
After a Snowflake ingestion run, some views show up in DataHub as datasets but have no SQL definition. The viewProperties aspect is missing for those views, the View Definition tab is greyed out, and lineage from the view SQL is missing. Other views in the same schema ingest correctly.
This happens when all of these are true:
- Your recipe sets
fetch_views_from_information_schema: true. The default isfalse. - One schema holds more than 1,000 views whose
VIEW_DEFINITIONinINFORMATION_SCHEMA.VIEWSis empty for the ingestion role. Snowflake showsVIEW_DEFINITIONthere only to the role that owns the view. - You run an
acryl-datahubversion older than 1.7.0.
Error Messages
The connector doesn't fail the run. Look for these lines in the ingestion log:
Fetching definitions for <N> views in <DB>.<SCHEMA> using batched 'SHOW VIEWS ... LIKE ...' queries. Found <N> batch(es).
Could not fetch definitions for <N> views in <DB>.<SCHEMA> after processing all batches.
You Might Be Asking
- Why are only some of my Snowflake views missing definitions while others ingest correctly?
- Which version of
acryl-datahubfixes this? - Is this a Snowflake permissions problem or a DataHub bug?
- Can I work around it before I upgrade?
Cause
In fetch_views_from_information_schema mode, the connector reads views from INFORMATION_SCHEMA.VIEWS. That view returns VIEW_DEFINITION only to the view's owner. For every view with an empty definition, the connector backfills the SQL with SHOW VIEWS LIKE '<prefix>%' IN SCHEMA queries. It groups the view names by shared prefix and runs one query per group.
A schema with 1,000 or fewer such views gets one group, so the backfill works. Above 1,000, the connector splits the names into several prefix groups and packs them into batches. Before 1.7.0, it ran a query only for the first group in each batch and skipped the rest. Views in the skipped groups kept an empty definition, so the connector emitted no viewProperties for them. Because the first group in every batch still ran, the loss is always partial.
acryl-datahub 1.7.0 fixes this. The connector now runs one SHOW VIEWS LIKE query for every prefix group.
Solution
Step 1: Confirm the cause
- Check your recipe. If it doesn't set
fetch_views_from_information_schema: true, this bug doesn't apply to you. - Check the CLI version the run used. It is printed at the start of the ingestion log, or run
datahub versionwhere you run the CLI. 1.7.0 and later have the fix. - As the DataHub ingestion role, count the views per schema with an empty definition:
SELECT TABLE_SCHEMA, COUNT(*) AS views_without_definition
FROM "<your_database>".INFORMATION_SCHEMA.VIEWS
WHERE TABLE_SCHEMA != 'INFORMATION_SCHEMA'
AND (VIEW_DEFINITION IS NULL OR VIEW_DEFINITION = '')
GROUP BY TABLE_SCHEMA;
An empty definition here is normal for views the role doesn't own, and the connector is built to handle it. If the affected views sit in a schema with a count above 1,000, and the log shows Could not fetch definitions for <N> views ... for that schema, you hit this bug.
Granting privileges doesn't change this query's result. Only the owner sees VIEW_DEFINITION in INFORMATION_SCHEMA.VIEWS.
Step 2: Upgrade acryl-datahub (the fix)
Upgrade to 1.7.0 or later. The latest release is best.
If you run the CLI yourself:
pip install --upgrade "acryl-datahub[snowflake]>=1.7.0"
datahub version
If you pin the version in a Dockerfile, put the extra before the version:
ARG DATAHUB_CLI_VERSION=1.7.0.20
RUN pip install "acryl-datahub[snowflake]==${DATAHUB_CLI_VERSION}"
If you run ingestion from the DataHub UI, open the Snowflake source, go to Advanced Settings, and set CLI Version to 1.7.0 or later.
Step 3: Workaround before you upgrade
Remove fetch_views_from_information_schema: true from the recipe, or set it to false. The connector then reads view definitions from SHOW VIEWS and skips the batched backfill. Make sure the ingestion role has the grants in the Snowflake Prerequisites, including references on all views and future views in the database.
On CLI versions older than 1.7.0, the connector's own docs say the SHOW VIEWS mode is unreliable for databases with more than 10,000 views. If your database is that large, upgrade instead. In the latest release, the SHOW VIEWS mode pages per schema, and the docs say you no longer need fetch_views_from_information_schema for databases with more than 10K views.
Don't narrow the recipe with table_pattern to re-ingest only the affected views. table_pattern doesn't filter views (that is view_pattern), and a re-run on an unfixed version runs the same backfill code.
Step 4: Re-run ingestion and check
- Re-run the Snowflake ingestion.
- Open a previously affected view in DataHub and check that the View Definition tab shows the SQL.
- Check the Lineage tab for its upstream tables.
Additional Notes
Secure views are a separate case. Snowflake hides the text of a secure view from roles that don't own it, both in INFORMATION_SCHEMA.VIEWS and in SHOW VIEWS. For a secure view with no definition, the connector reads the SQL from SNOWFLAKE.ACCOUNT_USAGE.VIEWS. That needs grant imported privileges on database snowflake to role <datahub_role>;, as listed in the Snowflake Prerequisites. Without it, the report shows "Failed to get secure views definitions". If the grant is in place but the view isn't in ACCOUNT_USAGE.VIEWS, the report shows "Secure view definition not found". To check whether a view is secure, run SHOW VIEWS IN SCHEMA <your_database>.<your_schema>; and look at the is_secure column.