Area: Ingestion Issues
Sub-Area: Snowflake Metadata Sync Automation
Applies to: Cloud
Issue
You use the Snowflake Metadata Sync automation to write DataHub table and column descriptions to Snowflake as comments. You see one or both of these problems:
- Descriptions you edit in DataHub don't show up as comments in Snowflake, even though the automation is running.
- You click Initialize, it finishes, but descriptions that existed in DataHub before you created the automation still don't show up in Snowflake.
The first problem comes from missing Snowflake privileges. The automation role needs OWNERSHIP on every table and view whose comment it updates.
The second problem depends on your DataHub Cloud version. Before v2.3.3, Initialize did not write descriptions at all. From v2.3.3, Initialize writes every description that a user edited in DataHub.
Error Messages
-
Failed to execute snowflake query: <query>. Exception: <Snowflake error>(a comment write failed; the Snowflake error says why, for example missing privileges) <N> Snowflake errors in the past hour; not issuing '<query>' to avoid locking the account. Last error: <error>
You Might Be Asking
- What Snowflake privileges does the automation role need to write comments?
- Does Initialize write descriptions, or only tags and terms?
- Which descriptions does Initialize write?
- Why did Initialize end as failed even though some comments were written?
- Where do I see what Initialize did?
Solution
Part 1: Grant the Snowflake privileges
To write a comment, the automation runs ALTER TABLE ... SET COMMENT, ALTER VIEW ... SET COMMENT, or ALTER TABLE|VIEW ... MODIFY COLUMN ... COMMENT. The role in the automation's connection settings needs:
-
USAGEon the database and schema. -
SELECTon the tables and views. -
OWNERSHIPon every table and view whose comment it updates.
These grants come from the Snowflake Metadata Sync prerequisites:
GRANT USAGE ON DATABASE your_database TO ROLE DATAHUB_AUTOMATION_ROLE;
GRANT USAGE ON SCHEMA your_database.your_schema TO ROLE DATAHUB_AUTOMATION_ROLE;
GRANT SELECT ON ALL TABLES IN SCHEMA your_database.your_schema TO ROLE DATAHUB_AUTOMATION_ROLE;
GRANT SELECT ON ALL VIEWS IN SCHEMA your_database.your_schema TO ROLE DATAHUB_AUTOMATION_ROLE;
GRANT OWNERSHIP ON ALL TABLES IN SCHEMA your_database.your_schema TO ROLE DATAHUB_AUTOMATION_ROLE;
GRANT OWNERSHIP ON ALL VIEWS IN SCHEMA your_database.your_schema TO ROLE DATAHUB_AUTOMATION_ROLE;
GRANT SELECT ON FUTURE TABLES IN SCHEMA your_database.your_schema TO ROLE DATAHUB_AUTOMATION_ROLE;
GRANT SELECT ON FUTURE VIEWS IN SCHEMA your_database.your_schema TO ROLE DATAHUB_AUTOMATION_ROLE;
GRANT OWNERSHIP ON FUTURE TABLES IN SCHEMA your_database.your_schema TO ROLE DATAHUB_AUTOMATION_ROLE;
GRANT OWNERSHIP ON FUTURE VIEWS IN SCHEMA your_database.your_schema TO ROLE DATAHUB_AUTOMATION_ROLE;
GRANT OWNERSHIP makes the automation role the owner of those objects. Check this with your Snowflake administrator before you run it. If your account can't give the role ownership of an object, the automation can't write its comment.
After you grant the privileges, run Initialize (Part 2). It skips comments that already match, so you can run it again safely.
Part 2: Backfill existing descriptions with Initialize
On the Automations page, open the automation's 3-dot menu and click Initialize. The menu item is disabled while Initialize runs.
What Initialize does depends on your DataHub Cloud version:
- Before v2.3.3: Initialize does not write descriptions. A Descriptions automation finishes Initialize quickly and writes nothing. Contact DataHub Support to upgrade.
- v2.3.3 and later: Initialize writes descriptions to Snowflake.
From v2.3.3, Initialize works like this for each Snowflake table and column:
- It writes the description a user edited in DataHub. It does not write descriptions that came from ingestion or from a YAML upsert.
- If the Snowflake comment already holds the same text, it skips the object.
- If the Snowflake comment is empty or different, it writes the DataHub text. The DataHub text replaces the old comment.
- It never clears a comment.
- It reports an object as not found when Snowflake doesn't have it, or the role can't see it.
- If a write fails, it continues with the other objects and then ends with the status FAILURE.
From v2.3.6, the automation form has the option Sync descriptions from logical models when you select Descriptions. It is off by default. When you turn it on, Initialize also writes the logical-model description of every Snowflake table and column linked to a logical model, unless the table or column has a description edited in DataHub. This replaces the existing comment. See Logical model descriptions. To change this option on an existing automation, stop the automation first, then edit it.
Part 3: Read the Initialize results
The Automations page shows only that Initialize is in progress. It doesn't show the counts or the failed objects.
The automation status that DataHub stores holds the result of the run: how many comments were written, unchanged, not found, and failed, the old text of each replaced comment, and the error of each failed or not found object (up to 500 of each). To read it, click Copy Urn in the automation's 3-dot menu, then query the status through the GraphQL API:
query {
actionPipeline(urn: "<automation urn>") {
status
}
}
For each failed object, fix the cause (usually the missing OWNERSHIP from Part 1) and run Initialize again.
Part 4: Descriptions edited after the automation starts
While the automation runs, it writes each description edit you make in DataHub to Snowflake as it happens. You don't need Initialize for new edits.
On versions before v2.3.3, Initialize can't backfill older descriptions. Until you upgrade, change each description in DataHub and save it. The running automation writes the new text to Snowflake.
Part 5: The error limit
The automation stops sending queries to Snowflake after 15 errors in one hour, so it doesn't lock the Snowflake user out. When this happens, the log shows <N> Snowflake errors in the past hour; not issuing '<query>' to avoid locking the account.
From v2.3.3, only connection and login errors count toward this limit. A failed statement, such as a write without the needed privilege, doesn't count. It shows up as a failed write instead.
If you hit the limit, fix the connection or login problem in the automation's connection settings. Errors older than one hour no longer count, so queries resume after that.