datahub-agent-context/src/datahub_agent_context/snowflake/README.md
This module provides tools to generate and deploy Snowflake UDFs (User-Defined Functions) that enable Snowflake Cortex Intelligence to query DataHub metadata.
The module generates SQL scripts to create:
UDFs use the datahub-agent-context package wrapper methods that abstract away GraphQL/REST API complexity.
python -m datahub.ai.snowflake.snowflake \
--sf-account YOUR_ACCOUNT \
--sf-user YOUR_USER \
--sf-role YOUR_ROLE \
--sf-warehouse YOUR_WAREHOUSE \
--sf-database YOUR_DATABASE \
--sf-schema YOUR_SCHEMA \
--datahub-url https://your-datahub.acryl.io \
--datahub-token YOUR_TOKEN \
--enable-mutations
Add --execute and --sf-password to automatically run the generated scripts:
python -m datahub.ai.snowflake.snowflake \
--sf-account YOUR_ACCOUNT \
--sf-user YOUR_USER \
--sf-password YOUR_PASSWORD \
--sf-role YOUR_ROLE \
--sf-warehouse YOUR_WAREHOUSE \
--sf-database YOUR_DATABASE \
--sf-schema YOUR_SCHEMA \
--datahub-url https://your-datahub.acryl.io \
--datahub-token YOUR_TOKEN \
--enable-mutations \
--execute
Use --sf-authenticator=externalbrowser for SSO authentication (no password required):
python -m datahub.ai.snowflake.snowflake \
--sf-account YOUR_ACCOUNT \
--sf-user YOUR_USER \
--sf-authenticator externalbrowser \
--sf-role YOUR_ROLE \
--sf-warehouse YOUR_WAREHOUSE \
--sf-database YOUR_DATABASE \
--sf-schema YOUR_SCHEMA \
--datahub-url https://your-datahub.acryl.io \
--datahub-token YOUR_TOKEN \
--enable-mutations \
--execute
This will open your browser for SSO authentication. Ideal for organizations using SAML, Okta, or other identity providers configured with Snowflake.
| Option | Description | Default |
|---|---|---|
--sf-account | Snowflake account identifier | Required |
--sf-user | Snowflake user name | Required |
--sf-role | Snowflake role | Required |
--sf-warehouse | Snowflake warehouse name | Required |
--sf-database | Snowflake database name | Required |
--sf-schema | Snowflake schema name | Required |
--datahub-url | DataHub instance URL | Required |
--datahub-token | DataHub Personal Access Token | Required |
--agent-name | Agent name in Snowflake | DATAHUB_SQL_AGENT |
--agent-display-name | Agent display name in UI | DataHub SQL Assistant |
--agent-color | Agent color in UI | blue |
--output-dir | Output directory for SQL files | ./snowflake_setup |
--enable-mutations | Include mutation/write tools (tags, descriptions, owners, etc.) | True (enabled) |
--no-enable-mutations | Disable mutation tools (read-only mode with 9 UDFs instead of 20) | N/A |
--execute | Execute scripts directly | False |
--sf-password | Snowflake password (required if --execute is used with snowflake authenticator) | None |
--sf-authenticator | Authentication method: snowflake (password), externalbrowser (SSO), or oauth (token-based) | snowflake |
Three authentication methods are supported when using --execute:
Standard username/password authentication:
--execute --sf-password YOUR_PASSWORD
Browser-based SSO authentication (SAML, Okta, Azure AD, etc.):
--execute --sf-authenticator externalbrowser
When using this method:
Token-based OAuth authentication:
--execute --sf-authenticator oauth
Note: OAuth authentication requires additional token configuration in your environment.
By default, the generator creates 20 UDFs including both read and write operations:
Use --no-enable-mutations to generate only the 9 read-only UDFs for environments where metadata modifications should be restricted.
--enable-mutations)If not using --execute, run the generated SQL files in order:
-- 1. Set up configuration and secrets
@00_configuration.sql;
-- 2. Create network rules
@01_network_rules.sql;
-- 3. Create DataHub UDFs
@02_datahub_udfs.sql;
-- 4. Create stored procedure
@03_stored_procedure.sql;
-- 5. Create Cortex Agent
@04_cortex_agent.sql;