Area: Ingestion Issues
Sub-Area: Snowflake Connector Configuration & Performance
Applies to: OSS + Cloud
Issue
Your Snowflake ingestion runs slowly, or runs slower after you set include_views: false, even though your recipe targets only a few tables. The cause is a bulk schema load from DataHub. It runs when lazy_schema_resolver is false and at least one of include_technical_schema, include_tables or include_views is false. The load fetches every schema DataHub holds for the recipe's platform, platform instance and env. It ignores database_pattern, schema_pattern and table_pattern.
Log messages that identify the bulk load
Search the run log for the message text. The module line numbers in the log prefix change between CLI versions, so don't match on them.
-
Fetching schemas for platform snowflake, env <ENV>(it can end with, name_starts_with <prefix>) Finished loading <N> schema info in <seconds> seconds
If the load returns nothing, the log shows Bulk schema fetch returned 0 results for platform=..., platform_instance=..., env=.... Schema resolver will be empty. If the load fails, the log shows Failed to bulk-load schemas from DataHub. Falling back to lazy-loading schema resolver. and the run continues with the lazy resolver.
You Might Be Asking
- Why does setting
include_views: falsemake my Snowflake ingestion slower? - Why is DataHub loading a very large number of schemas when my recipe targets a few hundred tables?
- What does
lazy_schema_resolverdo, and should I set it totrueorfalse? - How do I stop the "Fetching schemas for platform snowflake" bulk load?
Cause
lazy_schema_resolver defaults to true. With the default, no bulk load happens, whatever the include_* options are.
The bulk load runs only when both conditions hold:
-
lazy_schema_resolverisfalse. - At least one of
include_technical_schema,include_tablesorinclude_viewsisfalse. All three default totrue.
So include_tables: false or include_technical_schema: false triggers the same load as include_views: false.
The load fetches every schema DataHub holds for the recipe's platform, platform_instance and env. Your database, schema and table patterns don't narrow it.
Solution
-
Set
lazy_schema_resolver: true, or remove thelazy_schema_resolver: falseline. The default istrue. If you didn't set it tofalse, check whether a shared or copied recipe sets it.
source:
type: snowflake
config:
include_views: false
lazy_schema_resolver: true
-
Re-run the ingestion and check the log. Search for
Fetching schemas for platform snowflake. If the message is gone, the bulk load no longer runs.To see more detail, turn on debug logging. In a UI ingestion source, open Advanced Settings and turn on Debug Mode. For a CLI run, use
datahub --debug ingest -c recipe.yaml. Don't add adebugkey to the recipe, because recipes have no such key. See UI ingestion advanced settings. -
Know what the lazy resolver does. It fetches a table's schema from DataHub when the SQL parser first needs it. Those are tables that appear in parsed view definitions and queries. They can include tables outside your recipe patterns. The lazy resolver avoids the bulk fetch, but it is not limited to the tables your recipe ingests.
-
Optional: set patterns with fully qualified names. Patterns are Python regular expressions. They match from the start of the name, so anchor them for an exact match. Deny wins over allow. When
schema_patternis set andmatch_fully_qualified_namesisfalse(the default), the connector logs a warning. The warning saysfalseonly exists for backward compatibility and thattruewill become the default. Setmatch_fully_qualified_names: trueand match<database>.<schema>. Escape the dot, and use single quotes in YAML.
source:
type: snowflake
config:
lazy_schema_resolver: true
match_fully_qualified_names: true
database_pattern:
allow:
- '^MY_DATABASE$'
schema_pattern:
allow:
- '^MY_DATABASE\.MY_SCHEMA$'
-
Optional: split one account across recipes. Use
database_patternorschema_patternto divide the work. Keep the sameplatform_instancein every recipe, because it is part of every dataset URN. See platform instances.
On DataHub Cloud, you can make all of these changes in the recipe of your UI ingestion source. You don't need to change any server setting.
Related Documentation
- Snowflake source reference
- Snowflake config details
- Recipes
- UI ingestion advanced settings
- Platform instances
Tags: snowflake, ingestion, performance, include_views, lazy_schema_resolver, schema_resolver, bulk_fetch, recipe_configuration, slow_ingestion, sql_parsing