Area: Ingestion Issues
Sub-Area: dbt Source Ingestion / Assertions
Applies to: OSS + Cloud
Issue
You ran dbt source freshness, and sources.json shows passing freshness checks. You ingested your dbt project into DataHub, but you can't find the freshness results. The Summary tab's "Last Updated" field doesn't show the max_loaded_at time either.
You Might Be Asking
- Where do dbt source freshness results show up in DataHub after ingestion?
- Do dbt source freshness checks create assertions in DataHub?
- Why does
sources.jsonshowpassbut I see nothing in DataHub? - Does DataHub read freshness results from
run_results.json? - Why doesn't "Last Updated" show the dbt
max_loaded_attime?
Cause
The dbt source turns each source freshness result into a DataHub assertion. It doesn't put the result in "Last Updated". Results go missing for one of these reasons:
-
sources_pathisn't set in the recipe. The dbt source reads freshness results only fromsources.json. It doesn't read them fromrun_results.json. Fromrun_results.jsonit reads test results (entries whoseunique_idstarts withtest.) and model run timing. - The CLI that runs ingestion is too old. Older versions of the dbt source read
sources.jsononly for themax_loaded_attime and create no freshness assertions. - Test emission is turned off. The freshness assertion needs
entities_enabled.test_definitions, and its result needsentities_enabled.test_results. Both default toYes. If you set either one toNo, or set any otherentities_enabledfield toOnly, the source skips freshness assertions. - You're looking in the wrong place. The assertion is attached to the warehouse table (for example, the Snowflake table) that the dbt source points to. Results show on that table's Quality tab.
The max_loaded_at time goes to a different place. The dbt source writes it to lastModified in the dbt dataset's schemaMetadata aspect. The "Last Updated" field in the Summary tab reads lastModified from the dataset properties, and the dbt source doesn't set that field. So "Last Updated" never shows the dbt freshness time. This is expected.
Error Messages
Normally ingestion finishes with no error and no warning about freshness. If the source fails to build the assertion for one source node, the ingestion report shows Failed to emit freshness-assertion metadata.
Solution
-
Generate
sources.jsonwithdbt source freshness. For dbt Core, the file must includestatus,max_loaded_atandsnapshotted_atfor each source. The dbt source skips a source result that has nomax_loaded_atorsnapshotted_at. -
Set
sources_pathin your dbt recipe. It accepts a local path, ans3://URI or ags://URI.
source:
type: dbt
config:
manifest_path: "${DBT_PROJECT_ROOT}/target/manifest.json"
catalog_path: "${DBT_PROJECT_ROOT}/target/catalog.json"
sources_path: "${DBT_PROJECT_ROOT}/target/sources.json"
target_platform: snowflake
If your warehouse is ingested with its own platform_instance, also set target_platform_instance to the same value. The freshness assertion is attached to the warehouse table URN. Without the right instance, it points at a table that doesn't exist in DataHub. See the dbt source docs.
With the dbt-cloud source you don't need a file. It reads freshness results from the dbt Cloud job run.
-
Upgrade the CLI that runs your ingestion to the latest
acryl-datahubrelease. For UI-based ingestion, set the CLI version in the ingestion source's advanced settings. -
Leave
entities_enabled.test_definitionsandentities_enabled.test_resultsatYes, and don't set any otherentities_enabledfield toOnly. -
Run ingestion. Open the warehouse table in DataHub and go to the Quality tab. Each source with a freshness check gets a custom assertion of type
dbt Freshness. Each ingestion run with a newsources.jsonadds a run result. The run result keepsstatus,max_loaded_at,snapshotted_atandmax_loaded_at_time_ago_in_sfrom dbt.DataHub maps the dbt freshness status like this:
-
passbecomes SUCCESS. -
warnbecomes SUCCESS. If you settest_warnings_are_errors: true, it becomes FAILURE with LOW severity. -
error(theerror_afterthreshold was exceeded) becomes FAILURE with HIGH severity. -
runtime error(the check itself failed to run) becomes ERROR.
-
-
To check the raw
max_loaded_attime, read the dbt dataset'sschemaMetadataaspect with the CLI. Look atlastModified.time(epoch milliseconds).
datahub get --urn "urn:li:dataset:(urn:li:dataPlatform:dbt,<database>.<schema>.<table>,PROD)" --aspect schemaMetadata
If you set platform_instance in the dbt recipe, the URN name starts with <platform_instance>..