@@ -7092,6 +7092,47 @@ def test_asset_check_partitioned_planned_and_evaluation(
70927092 assert latest_c [check_key ].partition == "c"
70937093 assert latest_c [check_key ].status == AssetCheckExecutionRecordStatus .PLANNED
70947094
7095+ # Test get_asset_check_partition_records - returns all partitions with latest status
7096+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7097+ assert len (partition_records ) == 3
7098+
7099+ records_by_partition = {r .partition_key : r for r in partition_records }
7100+ assert set (records_by_partition .keys ()) == {"a" , "b" , "c" }
7101+
7102+ # Verify each partition has correct status
7103+ assert (
7104+ records_by_partition ["a" ].last_execution_status
7105+ == AssetCheckExecutionRecordStatus .SUCCEEDED
7106+ )
7107+ assert (
7108+ records_by_partition ["b" ].last_execution_status
7109+ == AssetCheckExecutionRecordStatus .FAILED
7110+ )
7111+ assert (
7112+ records_by_partition ["c" ].last_execution_status
7113+ == AssetCheckExecutionRecordStatus .PLANNED
7114+ )
7115+
7116+ # Verify all records have the same run_id (all planned in same run)
7117+ assert records_by_partition ["a" ].last_planned_run_id == run_id
7118+ assert records_by_partition ["b" ].last_planned_run_id == run_id
7119+ assert records_by_partition ["c" ].last_planned_run_id == run_id
7120+
7121+ # Verify last_storage_id is set for all records (this is the row id in the table)
7122+ assert records_by_partition ["a" ].last_storage_id is not None
7123+ assert records_by_partition ["b" ].last_storage_id is not None
7124+ assert records_by_partition ["c" ].last_storage_id is not None
7125+
7126+ # Verify last_materialization_storage_id is None for all records (no materializations)
7127+ assert records_by_partition ["a" ].last_materialization_storage_id is None
7128+ assert records_by_partition ["b" ].last_materialization_storage_id is None
7129+ assert records_by_partition ["c" ].last_materialization_storage_id is None
7130+
7131+ filtered_records = storage .get_asset_check_partition_info (
7132+ [check_key ], after_storage_id = 999999
7133+ )
7134+ assert len (filtered_records ) == 0
7135+
70957136 def test_asset_check_partitioned_multiple_runs_same_partition (
70967137 self ,
70977138 storage : EventLogStorage ,
@@ -7107,22 +7148,54 @@ def test_asset_check_partitioned_multiple_runs_same_partition(
71077148 partitions_def = dg .StaticPartitionsDefinition (["a" ])
71087149 partitions_subset = partitions_def .subset_with_partition_keys (["a" ])
71097150
7110- # Run 1: Store planned + evaluation for partition "a" with passed=True
7151+ # Run 1: Store planned event for partition "a"
71117152 storage .store_event (
71127153 _create_check_planned_event (run_id_1 , check_key , partitions_subset = partitions_subset )
71137154 )
7155+
7156+ # status for partition "a" should be PLANNED
7157+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7158+ assert len (partition_records ) == 1
7159+ record = partition_records [0 ]
7160+ assert record .partition_key == "a"
7161+ assert record .last_execution_status == AssetCheckExecutionRecordStatus .PLANNED
7162+ assert record .last_planned_run_id == run_id_1
7163+
7164+ # Run 1: Now store evaluation event for partition "a" with passed=True
71147165 storage .store_event (
71157166 _create_check_evaluation_event (run_id_1 , check_key , passed = True , partition = "a" )
71167167 )
71177168
7169+ # status for partition "a" should be SUCCEEDED
7170+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7171+ assert len (partition_records ) == 1
7172+ record = partition_records [0 ]
7173+ assert record .partition_key == "a"
7174+ assert record .last_execution_status == AssetCheckExecutionRecordStatus .SUCCEEDED
7175+ assert record .last_planned_run_id == run_id_1
7176+
71187177 # Run 2: Store planned + evaluation for partition "a" with passed=False
71197178 storage .store_event (
71207179 _create_check_planned_event (run_id_2 , check_key , partitions_subset = partitions_subset )
71217180 )
7181+
7182+ # back to PLANNED
7183+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7184+ record = partition_records [0 ]
7185+ assert record .last_execution_status == AssetCheckExecutionRecordStatus .PLANNED
7186+ assert record .last_planned_run_id == run_id_2
7187+
7188+ # Run 2: Now store evaluation event for partition "a" with passed=False
71227189 storage .store_event (
71237190 _create_check_evaluation_event (run_id_2 , check_key , passed = False , partition = "a" )
71247191 )
71257192
7193+ # onto FAILED
7194+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7195+ record = partition_records [0 ]
7196+ assert record .last_execution_status == AssetCheckExecutionRecordStatus .FAILED
7197+ assert record .last_planned_run_id == run_id_2
7198+
71267199 # Verify get_asset_check_execution_history returns 2 records for partition "a"
71277200 checks = storage .get_asset_check_execution_history (check_key , limit = 10 , partition = "a" )
71287201 assert len (checks ) == 2
@@ -7149,6 +7222,16 @@ def test_asset_check_partitioned_multiple_runs_same_partition(
71497222 assert check_key in latest_overall
71507223 assert latest_overall [check_key ].run_id == run_id_2
71517224
7225+ # Test get_asset_check_partition_records returns only the latest record per partition
7226+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7227+ assert len (partition_records ) == 1 # Only partition "a" exists
7228+
7229+ record = partition_records [0 ]
7230+ assert record .partition_key == "a"
7231+ # Should be the latest execution (run_id_2, FAILED)
7232+ assert record .last_execution_status == AssetCheckExecutionRecordStatus .FAILED
7233+ assert record .last_planned_run_id == run_id_2
7234+
71527235 def test_asset_check_partitioned_with_target_materialization (
71537236 self ,
71547237 storage : EventLogStorage ,
@@ -7210,6 +7293,12 @@ def test_asset_check_partitioned_with_target_materialization(
72107293 assert check_data .target_materialization_data
72117294 assert check_data .target_materialization_data .storage_id == m1_storage_id
72127295
7296+ # Verify get_asset_check_partition_records returns M1 as the latest materialization
7297+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7298+ assert len (partition_records ) == 1
7299+ record = partition_records [0 ]
7300+ assert record .last_materialization_storage_id == m1_storage_id
7301+
72137302 # Store materialization M2 for partition "a"
72147303 storage .store_event (_create_materialization_event (run_id_2 , asset_key , partition = "a" ))
72157304
@@ -7237,6 +7326,19 @@ def test_asset_check_partitioned_with_target_materialization(
72377326 assert check_data .target_materialization_data .storage_id == m1_storage_id
72387327 assert check_data .target_materialization_data .storage_id != m2_storage_id
72397328
7329+ # Test get_asset_check_partition_records includes target_materialization_storage_id
7330+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7331+ assert len (partition_records ) == 1
7332+
7333+ record = partition_records [0 ]
7334+ assert record .partition_key == "a"
7335+ assert record .last_execution_status == AssetCheckExecutionRecordStatus .SUCCEEDED
7336+ assert record .last_planned_run_id == run_id_1
7337+ # Verify last_execution_target_materialization_storage_id matches M1 (what check targeted)
7338+ assert record .last_execution_target_materialization_storage_id == m1_storage_id
7339+ # Verify last_materialization_storage_id matches M2 (the current latest materialization)
7340+ assert record .last_materialization_storage_id == m2_storage_id
7341+
72407342
72417343def _create_check_planned_event (
72427344 run_id : str ,
0 commit comments