airajena commented on code in PR #102:
URL: 
https://github.com/apache/fineract-business-intelligence/pull/102#discussion_r4318487082


##########
dbt/macros/incremental_windows.sql:
##########
@@ -0,0 +1,79 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+
+{% macro mart_recompute_window(date_column, scope_column='from_date') -%}
+    select
+        coalesce(sf.source_id, mm.source_id) as source_id,
+        least(
+            coalesce(sf.scope_from, mm.max_date + 1),
+            coalesce(mm.max_date + 1, sf.scope_from)
+        ) as recompute_from
+    from (
+        select
+            source_id,
+            min({{ scope_column }}) as scope_from
+        from {{ ref('int_snapshot_scope') }}
+        group by source_id
+    ) as sf
+    full outer join (
+        select
+            source_id,
+            max({{ date_column }}) as max_date
+        from {{ this }}
+        group by source_id
+    ) as mm
+        on sf.source_id = mm.source_id
+{%- endmacro %}
+
+{% macro mart_delete_recompute_window(date_column, scope_column='from_date') 
-%}
+    {%- if is_incremental() -%}
+        delete from {{ this }} as m
+        using ({{ mart_recompute_window(date_column, scope_column) }}) as w
+        where m.source_id = w.source_id and m.{{ date_column }} >= 
w.recompute_from
+    {%- else -%}
+        select 1
+    {%- endif -%}
+{%- endmacro %}
+
+{% macro advance_change_cursor(results) -%}
+    {%- if execute -%}
+        {%- set failed = results | selectattr('status', 'in', ['error', 
'fail', 'runtime error']) | list -%}
+        {%- set built = results | selectattr('node.name', 'equalto', 
'int_change_window')

Review Comment:
   Fixed. Each consumer now has its own cursor: the fact in dbt_change_cursor, 
each mart in dbt_mart_cursor. A cursor advances only from that model's own 
successful build, and test failures no longer freeze it. Marts recompute per 
(source, office, product), including the partition a loan or client moved away 
from. History-relevant columns decide what gets logged. The equivalence script 
checks that incremental equals full refresh, and that a partial build moves 
only the cursor of the mart it built.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to