test(pyamber): add unit tests for IcebergTableWriter - #7579
Merged
Conversation
Add mocked-catalog unit tests covering buffer-threshold flushing, close/open/remove_one semantics, and the tenacity commit-retry paths.
Contributor
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7579 +/- ##
=========================================
Coverage 87.88% 87.89%
Complexity 4276 4276
=========================================
Files 1176 1176
Lines 47018 47018
Branches 5245 5245
=========================================
+ Hits 41323 41325 +2
+ Misses 3972 3970 -2
Partials 1723 1723
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
✅ No material benchmark regressions detected🟢 7 better · 🔴 0 worse · ⚪ 8 noise (<±5%) · 0 without baseline
Baseline detailsLatest main
Raw CSVconfig_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,491.82,200,128000,407,0.248,23800.27,33676.64,33676.64
1,100,10,64,20,2489.88,2000,1280000,803,0.490,124429.26,142300.40,142300.40
2,1000,10,64,20,22065.34,20000,12800000,906,0.553,1107821.12,1156913.28,1156913.28 |
Contributor
Author
|
/request-review @aglinxinyuan |
aglinxinyuan
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this PR?
This PR adds
amber/src/test/python/core/storage/iceberg/test_iceberg_table_writer.pywith 14 pure unit tests using mocked catalog/table objects (no real Iceberg catalog, no Postgres, no network). Covered behaviors:catalog.load_table(f"{namespace}.{name}")and takesbuffer_sizefromStorageConfig.ICEBERG_TABLE_COMMIT_BATCH_SIZE.put_onebelow the threshold does not flush; reachingbuffer_sizetriggers a flush (serde called with schema + buffered items,table.appendcalled with serde's result, buffer cleared); items added after a flush start a fresh buffer.close()flushes the remaining items when the buffer is non-empty, and performs no append when the buffer is empty.open()clears a previously dirty buffer.remove_one()removes a buffered item; removing an item already flushed out of the buffer raisesValueError(pinning the currentlist.removebehavior)._flush_buffer()returns early on an empty buffer (no serde/append/refresh calls).table.appendraising pyiceberg'sCommitFailedExceptiontwice then succeeding completes the flush, withtable.refresh()called once per attempt; a permanent failure is reraised after 10 attempts and the buffer is NOT cleared.ValueError) is also retried for all 10 attempts before being reraised (pinning the current behavior).The retry tests patch
tenacity.nap.time.sleep, so the exponential-backoff waits (wait_random_exponential(0.001, 10)) never sleep for real; the whole file runs in about a second.No production code is changed.
Any related issues, documentation, discussions?
Closes #7575
How was this PR tested?
This PR is itself test-only. The new spec was run with:
Result: 14 passed in about a second. The file is formatted with
black(unchanged by--check). The suite was mutation-checked: targeted mutations of the writer (flipping the>=threshold to>, dropping thebuffer.clear()after append, removingtable.refresh()in the retry body, makingclose()skip the flush, removing the empty-buffer early return, and loweringstop_after_attempt) each caused at least one test to fail, and the source was restored afterwards.Was this PR authored or co-authored using generative AI tooling?
Co-authored by: Claude Code (Claude Fable 5)