@@ -7119,6 +7119,53 @@ def test_asset_check_partitioned_planned_and_evaluation(
71197119 assert latest_c [check_key ].partition == key_c
71207120 assert latest_c [check_key ].status == AssetCheckExecutionRecordStatus .PLANNED
71217121
7122+ # Test get_asset_check_partition_records - returns all partitions with latest status
7123+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7124+ assert len (partition_records ) == 3
7125+
7126+ records_by_partition = {r .partition_key : r for r in partition_records }
7127+ assert set (records_by_partition .keys ()) == set (partition_keys )
7128+
7129+ filtered_partition_records = storage .get_asset_check_partition_info (
7130+ [check_key ], partition_keys = [key_a , key_b ]
7131+ )
7132+ assert len (filtered_partition_records ) == 2
7133+ assert set (r .partition_key for r in filtered_partition_records ) == {key_a , key_b }
7134+
7135+ # Verify each partition has correct status
7136+ assert (
7137+ records_by_partition [key_a ].latest_execution_status
7138+ == AssetCheckExecutionRecordStatus .SUCCEEDED
7139+ )
7140+ assert (
7141+ records_by_partition [key_b ].latest_execution_status
7142+ == AssetCheckExecutionRecordStatus .FAILED
7143+ )
7144+ assert (
7145+ records_by_partition [key_c ].latest_execution_status
7146+ == AssetCheckExecutionRecordStatus .PLANNED
7147+ )
7148+
7149+ # Verify all records have the same run_id (all planned in same run)
7150+ assert records_by_partition [key_a ].latest_planned_run_id == run_id
7151+ assert records_by_partition [key_b ].latest_planned_run_id == run_id
7152+ assert records_by_partition [key_c ].latest_planned_run_id == run_id
7153+
7154+ # Verify last_storage_id is set for all records (this is the row id in the table)
7155+ assert records_by_partition [key_a ].latest_check_event_storage_id is not None
7156+ assert records_by_partition [key_b ].latest_check_event_storage_id is not None
7157+ assert records_by_partition [key_c ].latest_check_event_storage_id is not None
7158+
7159+ # Verify last_materialization_storage_id is None for all records (no materializations)
7160+ assert records_by_partition [key_a ].latest_materialization_storage_id is None
7161+ assert records_by_partition [key_b ].latest_materialization_storage_id is None
7162+ assert records_by_partition [key_c ].latest_materialization_storage_id is None
7163+
7164+ filtered_records = storage .get_asset_check_partition_info (
7165+ [check_key ], after_storage_id = 999999
7166+ )
7167+ assert len (filtered_records ) == 0
7168+
71227169 def test_asset_check_partitioned_multiple_runs_same_partition (
71237170 self ,
71247171 storage : EventLogStorage ,
@@ -7134,22 +7181,54 @@ def test_asset_check_partitioned_multiple_runs_same_partition(
71347181 partitions_def = dg .StaticPartitionsDefinition (["a" ])
71357182 partitions_subset = partitions_def .subset_with_partition_keys (["a" ])
71367183
7137- # Run 1: Store planned + evaluation for partition "a" with passed=True
7184+ # Run 1: Store planned event for partition "a"
71387185 storage .store_event (
71397186 _create_check_planned_event (run_id_1 , check_key , partitions_subset = partitions_subset )
71407187 )
7188+
7189+ # status for partition "a" should be PLANNED
7190+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7191+ assert len (partition_records ) == 1
7192+ record = partition_records [0 ]
7193+ assert record .partition_key == "a"
7194+ assert record .latest_execution_status == AssetCheckExecutionRecordStatus .PLANNED
7195+ assert record .latest_planned_run_id == run_id_1
7196+
7197+ # Run 1: Now store evaluation event for partition "a" with passed=True
71417198 storage .store_event (
71427199 _create_check_evaluation_event (run_id_1 , check_key , passed = True , partition = "a" )
71437200 )
71447201
7202+ # status for partition "a" should be SUCCEEDED
7203+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7204+ assert len (partition_records ) == 1
7205+ record = partition_records [0 ]
7206+ assert record .partition_key == "a"
7207+ assert record .latest_execution_status == AssetCheckExecutionRecordStatus .SUCCEEDED
7208+ assert record .latest_planned_run_id == run_id_1
7209+
71457210 # Run 2: Store planned + evaluation for partition "a" with passed=False
71467211 storage .store_event (
71477212 _create_check_planned_event (run_id_2 , check_key , partitions_subset = partitions_subset )
71487213 )
7214+
7215+ # back to PLANNED
7216+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7217+ record = partition_records [0 ]
7218+ assert record .latest_execution_status == AssetCheckExecutionRecordStatus .PLANNED
7219+ assert record .latest_planned_run_id == run_id_2
7220+
7221+ # Run 2: Now store evaluation event for partition "a" with passed=False
71497222 storage .store_event (
71507223 _create_check_evaluation_event (run_id_2 , check_key , passed = False , partition = "a" )
71517224 )
71527225
7226+ # onto FAILED
7227+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7228+ record = partition_records [0 ]
7229+ assert record .latest_execution_status == AssetCheckExecutionRecordStatus .FAILED
7230+ assert record .latest_planned_run_id == run_id_2
7231+
71537232 # Verify get_asset_check_execution_history returns 2 records for partition "a"
71547233 checks = storage .get_asset_check_execution_history (check_key , limit = 10 , partition = "a" )
71557234 assert len (checks ) == 2
@@ -7176,6 +7255,16 @@ def test_asset_check_partitioned_multiple_runs_same_partition(
71767255 assert check_key in latest_overall
71777256 assert latest_overall [check_key ].run_id == run_id_2
71787257
7258+ # Test get_asset_check_partition_records returns only the latest record per partition
7259+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7260+ assert len (partition_records ) == 1 # Only partition "a" exists
7261+
7262+ record = partition_records [0 ]
7263+ assert record .partition_key == "a"
7264+ # Should be the latest execution (run_id_2, FAILED)
7265+ assert record .latest_execution_status == AssetCheckExecutionRecordStatus .FAILED
7266+ assert record .latest_planned_run_id == run_id_2
7267+
71797268 def test_asset_check_partitioned_with_target_materialization (
71807269 self ,
71817270 storage : EventLogStorage ,
@@ -7237,6 +7326,12 @@ def test_asset_check_partitioned_with_target_materialization(
72377326 assert check_data .target_materialization_data
72387327 assert check_data .target_materialization_data .storage_id == m1_storage_id
72397328
7329+ # Verify get_asset_check_partition_records returns M1 as the latest materialization
7330+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7331+ assert len (partition_records ) == 1
7332+ record = partition_records [0 ]
7333+ assert record .latest_materialization_storage_id == m1_storage_id
7334+
72407335 # Store materialization M2 for partition "a"
72417336 storage .store_event (_create_materialization_event (run_id_2 , asset_key , partition = "a" ))
72427337
@@ -7264,6 +7359,19 @@ def test_asset_check_partitioned_with_target_materialization(
72647359 assert check_data .target_materialization_data .storage_id == m1_storage_id
72657360 assert check_data .target_materialization_data .storage_id != m2_storage_id
72667361
7362+ # Test get_asset_check_partition_records includes target_materialization_storage_id
7363+ partition_records = storage .get_asset_check_partition_info ([check_key ])
7364+ assert len (partition_records ) == 1
7365+
7366+ record = partition_records [0 ]
7367+ assert record .partition_key == "a"
7368+ assert record .latest_execution_status == AssetCheckExecutionRecordStatus .SUCCEEDED
7369+ assert record .latest_planned_run_id == run_id_1
7370+ # Verify last_execution_target_materialization_storage_id matches M1 (what check targeted)
7371+ assert record .latest_target_materialization_storage_id == m1_storage_id
7372+ # Verify last_materialization_storage_id matches M2 (the current latest materialization)
7373+ assert record .latest_materialization_storage_id == m2_storage_id
7374+
72677375
72687376def _create_check_planned_event (
72697377 run_id : str ,
0 commit comments