It is not possible to change the execution order so that your custom on-run-end hook runs after the Elementary package’s on-run-end hook. In dbt, project-level hooks always run before package hooks, and there is no built-in way to override this order. This means that if you add your own on-run-end hook in your dbt project, it will execute before Elementary’s on-run-end hook, not after it. This is a limitation of dbt’s hook system and is confirmed by both Elementary support and community members: > "on a dbt level, there is no way to do such a thing, package hooks will always run after the project hooks..." [Slack: Custom on-run-end after Elementary](
https://slack.com/archives/C02CTC89LAX/p1710369355415909) > "we want to create a macro that runs after the elementary on-run-end hook... is there any way to switch the order, or force the macro to run after the elementary?" > "no. Better use models which depend on Elementary's models" [Slack: Macro after Elementary on-run-end](
https://slack.com/archives/C02CTC89LAX/p1720098120068859)
Workarounds: - Instead of using an on-run-end hook, you can create a dbt model that depends on the Elementary models (such as
elementary_test_results
or
dbt_run_results
). This way, your aggregation logic will always run after Elementary has updated its tables, ensuring you have the latest results. - Alternatively, you can manually disable Elementary’s automatic result uploads and call the relevant Elementary macros yourself in the desired order within your own on-run-end hooks, but this is more complex and not generally recommended unless you have a strong need for custom orchestration [Slack: Custom on-run-end sequencing](
https://slack.com/archives/C02CTC89LAX/p1666183249043369).
Summary: You cannot override the Elementary on-run-end hook to add your step after it within the dbt hook system. The recommended approach is to use dbt models that depend on Elementary’s result tables for your aggregation logic.