Area: Ingestion Issues
Sub-Area: Snowflake Connector Performance Tuning
Applies to: OSS + Cloud
Issue
Snowflake ingestion takes a long time, even when your recipe targets one table and you don't need lineage or usage. You want to cut the run time with recipe settings.
You Might Be Asking
- Why is
SHOW TAGSrunning at the start of every run, and how do I skip it? - Why does ingestion still query
SNOWFLAKE.ACCOUNT_USAGEwhen I turned off lineage and usage? - What does
push_down_metadata_patternsdo, and how do I write patterns for it? - My recipe fails with
Extra inputs are not permittedforexclude_external_tables. What do I use instead?
Cause
The Snowflake source does several things by default, whatever your patterns are:
-
SHOW TAGS. When
known_snowflake_editionis not set, the source runsshow tagsto find out if your account is Standard edition or Enterprise or above. -
Python side filtering. With
push_down_metadata_patterns: false(the default), the source reads every database frominformation_schema.databases, every schema of each allowed database, and every table of each allowed database. It then drops what yourdatabase_pattern,schema_patternandtable_patterndon't allow. -
Query history. With
use_queries_v2: true(the default), the source runs the queries extractor. It always readsSNOWFLAKE.ACCOUNT_USAGE.USERS, and it reads the query log while any ofinclude_table_lineage,include_usage_stats,include_operational_stats,include_queriesorinclude_query_usage_statisticsis on. The last three default totrue, so turning off lineage and usage alone does not skip the query log. -
Operation history. With
use_queries_v2: false, the older extractor still reads Snowflake access history to build operations whileinclude_operational_statsistrue, which is the default. -
Extra object types. Primary keys (
show primary keys), foreign keys (show imported keys), views, streams and procedures are fetched per schema by default.
Solution
-
Use DataHub CLI 1.5.0 or later.
push_down_metadata_patterns,table_typesandexclude_dynamic_tablesare not in CLI 1.4.0.3 or older. The recipe rejects any key the CLI doesn't know withExtra inputs are not permitted. Upgrading to the latest CLI release is best. -
Add these settings to
source.config. Keep the ones you need and drop the rest. The Snowflake config details list every option and default.source: type: snowflake config: account_id: "<your-account-id>" username: "<your-username>" password: "<your-password>" warehouse: "<your-warehouse>" role: "<your-role>" # Skips SHOW TAGS. Valid values: "Standard" or "Enterprise or above". known_snowflake_edition: "Enterprise or above" # Filters databases, schemas and tables in Snowflake SQL (RLIKE). push_down_metadata_patterns: true # Drops external tables. The default is BASE TABLE and EXTERNAL TABLE. table_types: - BASE TABLE # Drops dynamic tables. table_types alone does not. exclude_dynamic_tables: true # Skips the queries extractor, including ACCOUNT_USAGE.USERS. use_queries_v2: false include_table_lineage: false include_usage_stats: false # Without this, the older extractor still reads access history. include_operational_stats: false include_primary_keys: false include_foreign_keys: false include_view_definitions: false include_streams: false include_procedures: false # Only if you don't need views: include_views: false match_fully_qualified_names: true database_pattern: allow: - "<YOUR_DATABASE>$" schema_pattern: allow: - "<YOUR_DATABASE>.<YOUR_SCHEMA>$" table_pattern: allow: - "<YOUR_DATABASE>.<YOUR_SCHEMA>.<YOUR_TABLE>$"Set
known_snowflake_editionto the edition your account really has. With"Standard", the source skips usage and operation extraction and turns off semantic views. The valuesENTERPRISEandSTANDARDfail validation.Don't add
include_view_lineageorinclude_view_column_lineage. Both were removed in December 2024. The source ignores them and prints a warning telling you to remove them. -
Check your patterns before you turn on
push_down_metadata_patterns. SnowflakeRLIKEmust match the whole string. Pythonre.match(), used without pushdown, only anchors at the start. SoPRODmatchesPROD_DBwithout pushdown but not with it. UsePROD.*for a prefix. A full name such asMYDB.MYSCHEMA.MYTABLE$works both ways.-
table_patternalways matchesDATABASE.SCHEMA.TABLE. -
schema_patternmatchesDATABASE.SCHEMAonly whenmatch_fully_qualified_names: true. Otherwise it matches the schema name alone. - Pushdown covers
information_schemametadata queries only. Views come fromSHOW VIEWSby default, soview_patternis still filtered in Python unless you also setfetch_views_from_information_schema: true.
-
-
Run the ingestion and compare the run time with the previous run.
What still runs
-
show databasesruns on every run. No option skips it. Pushdown then filters theinformation_schema.databasesquery. - The source checks the current Snowflake version, role and warehouse at the start of each run.
- Snowflake
ACCOUNT_USAGEviews have a latency of 45 minutes to 3 hours. This affects lineage and usage, not the run time of metadata extraction.
exclude_external_tables
exclude_external_tables is not a Snowflake source option, so the recipe fails validation with Extra inputs are not permitted. To drop external tables, set table_types to ["BASE TABLE"]. To drop dynamic tables, set exclude_dynamic_tables: true.
Related Documentation
Tags: snowflake, ingestion-performance, recipe-configuration, push-down-filters, known-snowflake-edition, slow-ingestion, show-tags, table-patterns, snowflake-connector