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


##########
dbt/models/intermediate/int_change_window.sql:
##########
@@ -0,0 +1,31 @@
+-- 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,
+
+{{ config(materialized='table', post_hook=['analyze {{ this }}']) }}
+
+{% set fact = adapter.get_relation(database=target.database, 
schema='analytics', identifier='fact_loan_snapshot') %}
+
+select
+    coalesce(
+        (
+            select c.last_change_id
+            from {{ source('meta', 'dbt_change_cursor') }} c
+            where c.model_name = 'fact_loan_snapshot'
+        ),
+        0
+    )::bigint as last_change_id,
+    coalesce(
+        (select max(l.change_id) from {{ source('meta', 'entity_change_log') 
}} l),

Review Comment:
   Fixed as you suggested. entity_change_log now has a txid xid8 column, and 
the window only reads rows below pg_snapshot_xmin(pg_current_snapshot()). The 
cursor moves on that txid watermark. I added an integration test with two 
overlapping writer transactions to show a slow writer's row is never skipped.



-- 
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