Snowflake miner app
The Snowflake miner app mines query history from Snowflake to generate lineage and
usage (popularity) metrics. Build it with the SnowflakeMiner builder.
Unlike a crawler, a miner doesn't create a connection or take a credential. It
runs on an existing Snowflake connection and reuses that connection's own
credential—so you only supply the connection's qualifiedName.
Source extraction
To mine query history from an existing Snowflake connection:
- Python
Mine query history from Snowflake
from pyatlan.client.atlan import AtlanClient
from pyatlan.model.apps import SnowflakeMiner
client = AtlanClient()
response = (
SnowflakeMiner(client)
.connection( # (1)
qualified_name="default/snowflake/1700000000",
)
.start_date(1704067200) # (2)
.calculate_popularity(True) # (3)
.popularity_window_days(30) # (4)
.excluded_users(["SYSTEM", "ATLAN_SERVICE"]) # (5)
.run(name="snowflake-prod-miner") # (6)
)
print(response.slug, response.run_id)
- Required. The exact
qualifiedNameof the existing Snowflake connection to mine. The builder resolves that connection's credential automatically—no credential step is needed. - Optional. The date (as an epoch) from which to start mining query history.
- Optional. Generate popularity metrics from the mined query history.
- Optional. Number of days of history to consider when calculating popularity.
- Optional. Users (for example, service accounts) to exclude from usage metrics.
- Always pass an explicit
namefor miners. A miner has no connection display name to derive one from, so a bare.run()defaults the workflow name to the app id (snowflake-miner) and a second run collides (409 already exists).
Account-usage source
By default the miner reads from Snowflake's SNOWFLAKE.ACCOUNT_USAGE. To point it at
a different database/schema (for example, a clone)—all of these are optional:
- Python
Mine from a cloned account-usage database
(
SnowflakeMiner(client)
.connection(qualified_name="default/snowflake/1700000000")
.snowflake_database("cloned") # (1)
.database_name("SNOWFLAKE_CLONE") # (2)
.schema_name("ACCOUNT_USAGE") # (3)
.start_date(1704067200)
.run(name="snowflake-prod-miner")
)
- Use a
clonedSnowflake database instead of thedefault. - The Snowflake database name to mine from.
- The account-usage schema name in that database.
Advanced config
- Python
Custom feature-flag config
(
SnowflakeMiner(client)
.connection(qualified_name="default/snowflake/1700000000")
.start_date(1704067200)
.advanced_config("custom") # (1)
.custom_config('{"flag": true}') # (2)
.run(name="snowflake-prod-miner")
)
- Switch advanced config to
customto enable experimental feature flags. - Custom feature-flag config as a JSON string (used when
advanced_configiscustom).