Area: Ingestion Issues
Sub-Area: Snowflake Connector, Permissions and Schema Discovery
Applies to: OSS + Cloud
Issue
After a Snowflake ingestion run, some schemas and their tables are not in DataHub. There is no schema container and there are no datasets. The run succeeds. No schema_pattern or table_pattern deny rule excludes these schemas. When you check in Snowflake by hand, you can see the schemas.
Error Messages
When some schemas in a database are hidden from the ingestion role, the run reports nothing about them. When the role can see no schemas at all in a database, the run reports this warning for that database:
No schemas found in database. If schemas exist, please grant USAGE permissions on them.
When a schema is found but the role can see no objects in it, the run report has this info entry, with the schema as context:
-
No tables/views/semantic views/streams found in schema(If objects exist, please grant REFERENCES or SELECT permissions on them.)
You Might Be Asking
- Why are some Snowflake schemas missing from DataHub when ingestion succeeds and no pattern excludes them?
- Why can I see the schemas in Snowflake, but DataHub does not find them?
- How do I tell a schema that was never found from a schema that was found but looks empty?
- Does the DataHub Snowflake connector use secondary roles?
- Which Snowflake privileges does the ingestion role need?
- Does a separate targeted run affect my main source's stateful ingestion checkpoint?
Cause
The connector gets its list of schemas from this query, run once for each database it ingests:
SELECT schema_name, created, last_altered, comment
FROM "<YOUR_DATABASE>".information_schema.schemata
WHERE schema_name != 'INFORMATION_SCHEMA'
ORDER BY schema_name;
Snowflake returns only the schemas the session's roles can access. If the ingestion role has no USAGE on a schema, that schema is not in the result. The connector never sees it, so it creates no container and no datasets for it.
Your manual check can pass for two reasons:
- You ran it as a different user, such as an admin login, which has more roles.
- Your session had secondary roles active, and one of them has
USAGEon the schema.
The connector sets only the primary role, from the recipe's role key. It never runs USE SECONDARY ROLES. Snowflake can still turn on secondary roles for the ingestion user at login, based on that user's settings. The connector's own connection test reads CURRENT_SECONDARY_ROLES() for this reason. So don't depend on secondary roles. Grant the privileges to the ingestion role.
Solution
Step 1: Tell "never found" from "found but empty"
- The schema container is in DataHub but has no datasets: the connector found the schema but could not see its tables. The role lacks
REFERENCESorSELECTon the tables. The run report has theNo tables/views/semantic views/streams found in schemainfo entry for it. - There is no schema container at all: the schemata query did not return the schema. The role lacks
USAGEon the schema, or on the database. This article covers this case.
A schema container is created only when include_technical_schema is true, which is the default.
Step 2: See what the connector sees
Log in to Snowflake as the same user the recipe uses, not as an admin. Then run:
USE ROLE <YOUR_INGESTION_ROLE>;
SELECT CURRENT_ROLE(), CURRENT_SECONDARY_ROLES();
SELECT schema_name
FROM "<YOUR_DATABASE>".information_schema.schemata
WHERE schema_name != 'INFORMATION_SCHEMA'
ORDER BY schema_name;
If a schema is missing from the result, the connector does not see it either. To see which privileges the ingestion role itself holds, run:
SHOW GRANTS TO ROLE <YOUR_INGESTION_ROLE>;
Look for USAGE on the database and on each missing schema.
Step 3: Grant the privileges to the ingestion role
The ingestion role needs:
-
USAGEon the database -
USAGEon each schema -
REFERENCESon tables and views if you don't use profiling or classification, orSELECTif you do
GRANT USAGE ON DATABASE "<YOUR_DATABASE>" TO ROLE <YOUR_INGESTION_ROLE>;
GRANT USAGE ON ALL SCHEMAS IN DATABASE "<YOUR_DATABASE>" TO ROLE <YOUR_INGESTION_ROLE>;
GRANT USAGE ON FUTURE SCHEMAS IN DATABASE "<YOUR_DATABASE>" TO ROLE <YOUR_INGESTION_ROLE>;
GRANT REFERENCES ON ALL TABLES IN DATABASE "<YOUR_DATABASE>" TO ROLE <YOUR_INGESTION_ROLE>;
GRANT REFERENCES ON FUTURE TABLES IN DATABASE "<YOUR_DATABASE>" TO ROLE <YOUR_INGESTION_ROLE>;
GRANT REFERENCES ON ALL VIEWS IN DATABASE "<YOUR_DATABASE>" TO ROLE <YOUR_INGESTION_ROLE>;
GRANT REFERENCES ON FUTURE VIEWS IN DATABASE "<YOUR_DATABASE>" TO ROLE <YOUR_INGESTION_ROLE>;
The future grants cover schemas and tables that are created later, such as schemas with generated names. The full list of grants, including warehouse, external table, stream and dynamic table grants, is under Prerequisites on the Snowflake source page.
Run the Step 2 query again as the ingestion user. All the schemas you expect must now be in the result.
Step 4: Run ingestion again
Run your existing Snowflake source again, manually or on its schedule. You don't need to change the recipe. The connector lists the schemas again and ingests the ones it can now see.
If you want to ingest only the missing schemas first, make a separate source from a copy of your recipe. Keep the connection, authentication, env, platform_instance and convert_urns_to_lowercase values the same as the main recipe, so the run writes the same URNs. Then narrow the patterns and turn off stateful ingestion:
source:
type: snowflake
config:
# connection, authentication, env, platform_instance and
# convert_urns_to_lowercase: same as your main recipe
database_pattern:
allow:
- "^<YOUR_DATABASE>$"
match_fully_qualified_names: true
schema_pattern:
allow:
- "^<YOUR_DATABASE>\\.<YOUR_MISSING_SCHEMA>$"
stateful_ingestion:
enabled: false
pipeline_name: "<a-name-not-used-by-any-other-source>"
- Set
stateful_ingestion.enabled: falseexplicitly. When a recipe has apipeline_nameand writes to DataHub, stateful ingestion turns on by itself if you leave the block out. - With stateful ingestion off, the run does not read or write a checkpoint, and it soft deletes nothing.
- Checkpoints are stored against
pipeline_name. Give the separate source a name no other source uses. A source created in the DataHub UI gets a uniquepipeline_namefrom DataHub automatically.
convert_urns_to_lowercase defaults to true for Snowflake. If your main recipe sets it, copy the same value. A different value gives different URNs and duplicate datasets.
Step 5: Check the result
- Confirm the schema containers and their datasets are now in DataHub.
- Confirm the next run of the main source also finds them.
Related Documentation
Tags: snowflake, ingestion, missing-schemas, role-privileges, secondary-roles, usage-grant, schema-discovery, stateful-ingestion, permissions, snowflake-connector