Ken
July 30, 2024, 1:46am
1
I am using dbt-dremio to update my models in dremio.
I have the below dependency path in dbt
1.) fct_daily_shareholding_history (incremental)
2.) fct_daily_shareholding_change_history (incremental)
Item 2 depends on item 1.
I have issue with item 2, where new records are not found. Item 1 has the required new records.
I suspect that the
cause is that I have a reflection on item 1.
The reflection is also managed by dbt-dremio (using model=reflection).
However, dbt_dremio immediately returns after it kick-start the reflection and does not wait for it’s completion.
Now, when item 2 starts, it queries the outdated reflection (I can see it being accelerated on the UI).
So I suspect this explains why new records are only found in item 1, but not in item 2.
Ken
July 30, 2024, 5:14am
2
Is there a way to temporarily stop the query planner from considering reflection during dbt run?
Or is there a way, in dbt, to wait for the reflection to complete, before moving on to the next model??
Ken
July 30, 2024, 5:23am
3
Found this ALTER session command which can disable using reflection in the session.
Let me try this.
Ken
July 30, 2024, 12:12pm
4
HI all,
I followed the documentation here (Influencing the Choice of Reflections Used to Satisfy Queries | Dremio Documentation )
But I am getting EOF error in the dremio UI
============
It is now working after I remove the double quotes.
Ken
July 30, 2024, 1:32pm
5
I finally settled with this solution in my dbt project, where I want none of my models to use reflections.
on-run-start:
- '{{ turn_off_reflections() }}'
on-run-end:
- '{{ turn_on_reflections() }}'
{% macro turn_off_reflections() %}
ALTER SYSTEM SET reflections.planning.no_reflections=true;
{% endmacro %}
{% macro turn_on_reflections() %}
ALTER SYSTEM SET reflections.planning.no_reflections=false;
{% endmacro %}
The advantage of using SYSTEM
(alter system) ensures that everything is run without reflections during dbt run. This circumvents the problem of SESSION
(alter session), where only queries which run in a multi-statement block work. While this is quite doable on the Dremio UI, this is a bit difficult with dbt-dremio.
1 Like
Ken
July 31, 2024, 4:29pm
6
I created a video walkthrough of my solution here
2 Likes
Awesome work @Ken Thanks for sharing
1 Like