Skip to content

#739 Add snapshot properties (info_date, batch_id) to Iceberg writes.#770

Merged
yruslan merged 2 commits into
mainfrom
feature/739-add-pramen-snapshot-properties
Jul 3, 2026
Merged

#739 Add snapshot properties (info_date, batch_id) to Iceberg writes.#770
yruslan merged 2 commits into
mainfrom
feature/739-add-pramen-snapshot-properties

Conversation

@yruslan

@yruslan yruslan commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Closes #739

Summary by CodeRabbit

  • Bug Fixes

    • Iceberg metastore persistence now adds snapshot metadata for key fields consistently across appends, full overwrite, daily partition overwrite, and initial table creation.
    • Saved table snapshots now reliably reflect the expected write date and batch ID for improved traceability.
  • Tests

    • Expanded Iceberg persistence tests to cover all partition schemes and overwrite scenarios.
    • Added snapshot-summary assertions (e.g., for info date and batch ID) and improved how tables are loaded/validated during tests.

@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e163859f-f39a-41ec-9f25-7cd79fb0948b

📥 Commits

Reviewing files that changed from the base of the PR and between 3ef2733 and 08e81d7.

📒 Files selected for processing (2)
  • pramen/core/src/main/scala/za/co/absa/pramen/core/metastore/peristence/MetastorePersistenceIceberg.scala
  • pramen/core/src/test/scala/za/co/absa/pramen/core/metastore/persistence/MetastorePersistenceIcebergLongSuite.scala
🚧 Files skipped from review as they are similar to previous changes (2)
  • pramen/core/src/test/scala/za/co/absa/pramen/core/metastore/persistence/MetastorePersistenceIcebergLongSuite.scala
  • pramen/core/src/main/scala/za/co/absa/pramen/core/metastore/peristence/MetastorePersistenceIceberg.scala

Walkthrough

Iceberg writes now attach snapshot-property metadata derived from the info-date and batch-id columns across append, overwrite, and table-creation paths. The Iceberg long suite now uses Iceberg-specific persistence construction and checks the resulting snapshot summary values.

Changes

Iceberg Snapshot Metadata

Layer / File(s) Summary
Write options enrichment with snapshot metadata
pramen/core/src/main/scala/za/co/absa/pramen/core/metastore/peristence/MetastorePersistenceIceberg.scala
saveTable now builds writerOptionsWithAdditionalMetadata with snapshot-property.<col> entries for infoDateColumn and batchIdColumn, and uses it for append, full overwrite, daily partition overwrite, and table creation.
Iceberg persistence helper and snapshot assertions
pramen/core/src/test/scala/za/co/absa/pramen/core/metastore/persistence/MetastorePersistenceIcebergLongSuite.scala
The suite switches to getIcebergMtPersistence(...) across partition cases, refactors table partition loading through loadIcebergTable(...), and adds daily snapshot-summary checks for info_date and pramen_batchid.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Test as MetastorePersistenceIcebergLongSuite
  participant Persistence as MetastorePersistenceIceberg
  participant Iceberg as Iceberg table

  Test->>Persistence: getIcebergMtPersistence(...)
  Test->>Persistence: saveTable(writeOptions)
  Persistence->>Persistence: add snapshot-property.info_date and snapshot-property.pramen_batchid
  Persistence->>Iceberg: append / overwrite / create with enriched options
  Test->>Iceberg: currentSnapshot().summary()
  Iceberg-->>Test: info_date, pramen_batchid
Loading

Possibly related PRs

  • AbsaOSS/pramen#622: Both PRs modify MetastorePersistenceIceberg.saveTable behavior around overwrite handling, so the metadata injection here lands on the same write path family.

Poem

A rabbit wrote by moonlit gleam,
With batch and date in Iceberg’s stream.
Hop, snapshot, sealed so neat,
A tiny trail for each write feat.
🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing the required Overview and Release Notes sections and only contains the issue reference. Add an Overview, at least two Release Notes bullets, and a Related section with the linked issue number.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding snapshot properties to Iceberg writes.
Linked Issues check ✅ Passed The code adds Iceberg snapshot metadata for the write path, matching the requested table properties for writes.
Out of Scope Changes check ✅ Passed The changes shown are focused on the Iceberg snapshot-property feature and related tests, with no clear unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/739-add-pramen-snapshot-properties

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pramen/core/src/test/scala/za/co/absa/pramen/core/metastore/persistence/MetastorePersistenceIcebergLongSuite.scala (1)

91-99: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate table-loading logic with getTablePartitions.

Loading the Iceberg table via HadoopTables/Path to inspect metadata duplicates the same logic already in getTablePartitions (Lines 196-199). Consider extracting a shared loadIcebergTable(tableName) helper used by both.

♻️ Proposed refactor
+  def loadIcebergTable(tableName: String): Table = {
+    val location = new Path(hadoopTempDir, s"pramen/iceberg_catalog/default/$tableName").toString
+    new HadoopTables().load(location)
+  }
+
   def getTablePartitions(tableName: String): Seq[String] = {
-    val location = new Path(hadoopTempDir, s"pramen/iceberg_catalog/default/$tableName").toString
-    val ht = new HadoopTables
-    val table = ht.load(location)
+    val table = loadIcebergTable(tableName)

     table.spec()
       ...

And in the test:

-        val location = new Path(hadoopTempDir, s"pramen/iceberg_catalog/default/$tableName").toString
-        val ht = new HadoopTables
-        val table = ht.load(location)
-        val snapshotProperties = table.currentSnapshot().summary().asScala
+        val snapshotProperties = loadIcebergTable(tableName).currentSnapshot().summary().asScala
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@pramen/core/src/test/scala/za/co/absa/pramen/core/metastore/persistence/MetastorePersistenceIcebergLongSuite.scala`
around lines 91 - 99, The test repeats Iceberg table-loading logic instead of
reusing the existing approach already used by getTablePartitions. Extract a
shared loadIcebergTable(tableName) helper that builds the Path, creates
HadoopTables, and loads the table, then use that helper both in the
snapshot-properties assertions and in getTablePartitions so the table lookup
lives in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@pramen/core/src/test/scala/za/co/absa/pramen/core/metastore/persistence/MetastorePersistenceIcebergLongSuite.scala`:
- Around line 91-99: The test repeats Iceberg table-loading logic instead of
reusing the existing approach already used by getTablePartitions. Extract a
shared loadIcebergTable(tableName) helper that builds the Path, creates
HadoopTables, and loads the table, then use that helper both in the
snapshot-properties assertions and in getTablePartitions so the table lookup
lives in one place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d8f6d786-ff70-4fd1-a7f5-ff9a8b0de00b

📥 Commits

Reviewing files that changed from the base of the PR and between 9cdc2bc and 3ef2733.

📒 Files selected for processing (2)
  • pramen/core/src/main/scala/za/co/absa/pramen/core/metastore/peristence/MetastorePersistenceIceberg.scala
  • pramen/core/src/test/scala/za/co/absa/pramen/core/metastore/persistence/MetastorePersistenceIcebergLongSuite.scala

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Unit Test Coverage

Overall Project 76.84% -0.01% 🍏
Files changed 93.1% 🍏

Module Coverage
pramen:core Jacoco Report 77.82% -0.01% 🍏
Files
Module File Coverage
pramen:core Jacoco Report MetastorePersistenceIceberg.scala 81.03% -0.79% 🍏

@yruslan yruslan merged commit ca1caa5 into main Jul 3, 2026
7 checks passed
@yruslan yruslan deleted the feature/739-add-pramen-snapshot-properties branch July 3, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pramen_batchid, pramen_info_date property to Iceberg tables when writing to it

1 participant