|
18 | 18 |
|
19 | 19 | import unittest |
20 | 20 | from datetime import datetime |
21 | | -from unittest.mock import Mock, patch |
| 21 | +from unittest.mock import MagicMock, Mock, patch |
22 | 22 |
|
23 | 23 | from pypaimon.manifest.schema.data_file_meta import DataFileMeta |
24 | 24 | from pypaimon.manifest.schema.manifest_entry import ManifestEntry |
@@ -404,6 +404,49 @@ def test_generate_partition_statistics_empty_commit_messages( |
404 | 404 | # Verify results |
405 | 405 | self.assertEqual(len(statistics), 0) |
406 | 406 |
|
| 407 | + def test_append_commit_inherits_index_manifest( |
| 408 | + self, mock_manifest_list_manager, mock_manifest_file_manager, mock_snapshot_manager): |
| 409 | + file_store_commit = self._create_file_store_commit() |
| 410 | + |
| 411 | + self.mock_table.identifier = 'default.test_table' |
| 412 | + self.mock_table.table_schema = Mock() |
| 413 | + self.mock_table.table_schema.id = 7 |
| 414 | + self.mock_table.options.row_tracking_enabled.return_value = False |
| 415 | + |
| 416 | + snapshot_commit = MagicMock() |
| 417 | + snapshot_commit.__enter__.return_value = snapshot_commit |
| 418 | + snapshot_commit.__exit__.return_value = False |
| 419 | + snapshot_commit.commit.return_value = True |
| 420 | + file_store_commit.snapshot_commit = snapshot_commit |
| 421 | + |
| 422 | + file_store_commit._write_manifest_file = Mock(return_value=Mock()) |
| 423 | + file_store_commit._generate_partition_statistics = Mock(return_value=[]) |
| 424 | + file_store_commit.manifest_list_manager.read_all.return_value = [] |
| 425 | + |
| 426 | + latest_snapshot = Mock() |
| 427 | + latest_snapshot.id = 3 |
| 428 | + latest_snapshot.total_record_count = 10 |
| 429 | + latest_snapshot.index_manifest = "index-manifest-existing" |
| 430 | + |
| 431 | + commit_entry = Mock() |
| 432 | + commit_entry.kind = 0 |
| 433 | + commit_entry.file = Mock() |
| 434 | + commit_entry.file.row_count = 2 |
| 435 | + |
| 436 | + result = file_store_commit._try_commit_once( |
| 437 | + retry_result=None, |
| 438 | + commit_kind="APPEND", |
| 439 | + commit_entries=[commit_entry], |
| 440 | + commit_identifier=11, |
| 441 | + latest_snapshot=latest_snapshot |
| 442 | + ) |
| 443 | + |
| 444 | + self.assertTrue(result.is_success()) |
| 445 | + self.assertEqual( |
| 446 | + "index-manifest-existing", |
| 447 | + snapshot_commit.commit.call_args[0][0].index_manifest |
| 448 | + ) |
| 449 | + |
407 | 450 | def test_null_partition_value( |
408 | 451 | self, mock_manifest_list_manager, mock_manifest_file_manager, mock_snapshot_manager): |
409 | 452 | from pypaimon.data.timestamp import Timestamp |
|
0 commit comments