Fix of Error ERROR AHM must lag behind the create epoch of unrefreshed projection

On running the following command:

select make_ahm_now();
I got the following error ERROR: AHM must lag behind the create epoch of unrefreshed projection projection name. Here is small fix for Error :
  • something is wrong !
What is the reason ?
  • this error has to do with data consistency across all projections.
select
  projection_schema,
  anchor_table_name,
  projection_name,
  is_up_to_date
from projections
        where projection_name='<projection that appears in the error message';
projection_schema  anchor_table_name  projection_name  is_up_to_date
-----------------  -----------------  ---------------  -------------
staging            tbl name           proj name2_b0    false
  • we can see that the projection is not up-to-date, which means data was not replicated across all of the projections of the base table.
To fix this we need to refresh the base table:
select refresh('schema.table');
Now if you run the same query again:
select
  projection_schema,
  anchor_table_name,
  projection_name,
  is_up_to_date
from projections
        where projection_name='<projection that appears in the error message';
projection_schema  anchor_table_name  projection_name  is_up_to_date
-----------------  -----------------  ---------------  -------------
staging            tbl name           proj name2_b0    true
  • we can see that the projections are up-to-date.