@@ -1989,3 +1989,60 @@ def test_snapshot_pickle_intervals(make_snapshot):
19891989 assert not loaded_snapshot .dev_intervals
19901990 assert len (snapshot .intervals ) > 0
19911991 assert len (snapshot .dev_intervals ) > 0
1992+
1993+
1994+ def test_missing_intervals_interval_end_per_model (make_snapshot ):
1995+ snapshot_a = make_snapshot (
1996+ SqlModel (
1997+ name = "a" ,
1998+ start = "2023-01-04" ,
1999+ query = parse_one ("SELECT 1" ),
2000+ ),
2001+ version = "a" ,
2002+ )
2003+
2004+ snapshot_b = make_snapshot (
2005+ SqlModel (
2006+ name = "b" ,
2007+ start = "2023-01-04" ,
2008+ query = parse_one ("SELECT 2" ),
2009+ ),
2010+ version = "b" ,
2011+ )
2012+
2013+ assert missing_intervals (
2014+ [snapshot_a , snapshot_b ],
2015+ start = "2023-01-04" ,
2016+ end = "2023-01-10" ,
2017+ interval_end_per_model = {
2018+ snapshot_a .name : to_timestamp ("2023-01-09" ),
2019+ snapshot_b .name : to_timestamp ("2023-01-06" ),
2020+ },
2021+ ) == {
2022+ snapshot_a : [
2023+ (to_timestamp ("2023-01-04" ), to_timestamp ("2023-01-05" )),
2024+ (to_timestamp ("2023-01-05" ), to_timestamp ("2023-01-06" )),
2025+ (to_timestamp ("2023-01-06" ), to_timestamp ("2023-01-07" )),
2026+ (to_timestamp ("2023-01-07" ), to_timestamp ("2023-01-08" )),
2027+ (to_timestamp ("2023-01-08" ), to_timestamp ("2023-01-09" )),
2028+ ],
2029+ snapshot_b : [
2030+ (to_timestamp ("2023-01-04" ), to_timestamp ("2023-01-05" )),
2031+ (to_timestamp ("2023-01-05" ), to_timestamp ("2023-01-06" )),
2032+ ],
2033+ }
2034+
2035+ assert missing_intervals (
2036+ [snapshot_a , snapshot_b ],
2037+ start = "2023-01-08" ,
2038+ end = "2023-01-08" ,
2039+ interval_end_per_model = {
2040+ snapshot_a .name : to_timestamp ("2023-01-09" ),
2041+ snapshot_b .name : to_timestamp (
2042+ "2023-01-06"
2043+ ), # The interval end is before the start. This should be ignored.
2044+ },
2045+ ) == {
2046+ snapshot_a : [(to_timestamp ("2023-01-08" ), to_timestamp ("2023-01-09" ))],
2047+ snapshot_b : [(to_timestamp ("2023-01-08" ), to_timestamp ("2023-01-09" ))],
2048+ }
0 commit comments