Skip to content

Conversation

@cbb330
Copy link
Collaborator

@cbb330 cbb330 commented Sep 29, 2025

Summary

Implement Iceberg table branching functionality in OpenHouse internal catalog with comprehensive testing infrastructure.

The old code was getting unwieldy with nested for-loops, mutable collections, and scattered state management, repeated logic and overall needed a restructure with branching supported first-class. i feel more confident that this is reliable.

Changes

  • Branch Operations: Added branch management methods to OpenHouseInternalTableOperations including create, delete, list, and commit reference handling
  • Multi-branch Commit Support: Implemented logic to handle commits across different branch references with checks to reject ambiguous commits
  • WAP Branch Integration: Added Write-Audit-Publish (WAP) branch support with proper test coverage
  • Test Infrastructure: Created comprehensive test suite (BranchTestSpark3_5) covering branch operations, edge cases, and integration scenarios

Changes

  • Client-facing API Changes
  • Internal API Changes
  • Bug Fixes
  • New Features
  • Performance Improvements
  • Code Style
  • Refactoring
  • Documentation
  • Tests

Testing Done

  • Manually Tested on local docker setup. Please include commands ran, and their output.
  • Added new tests for the changes made.
  • Updated existing tests to reflect the changes made.
  • No tests added or updated. Please explain why. If unsure, please feel free to ask for help.
  • Some other form of testing like staging or soak time in production. Please explain.

Additional Information

  • Breaking Changes
  • Deprecations
  • Large PR broken into smaller PRs, and PR plan linked in the description.

Copy link
Collaborator

@sumedhsakdeo sumedhsakdeo left a comment

Choose a reason for hiding this comment

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

PTAL

@cbb330 cbb330 changed the title WIP: introduce branching and and wap branch WIP: introduce branching and support for spark.wap.branch Oct 2, 2025
@cbb330 cbb330 changed the title WIP: introduce branching and support for spark.wap.branch Introduce branching and support for spark.wap.branch Oct 2, 2025
Copy link
Collaborator

@jiang95-dev jiang95-dev left a comment

Choose a reason for hiding this comment

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

Thanks Christian for the comprehensive tests to ensure safety! I couldn't finish reading all of the tests, but I read through SnapshotDiffApplier and left some comments. I don't have concerns about correctness, but have some regarding readability and easiness to debug.

Comment on lines 391 to 408
int appendedCount =
(int)
regularSnapshots.stream()
.filter(s -> !existingById.containsKey(s.snapshotId()))
.count();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Related to the above comment. We should have regularSnapshots as appended regular snapshots.

@cbb330 cbb330 force-pushed the main branch 2 times, most recently from 8748e63 to 39b6cf1 Compare November 4, 2025 23:01
Copy link
Collaborator

@sumedhsakdeo sumedhsakdeo left a comment

Choose a reason for hiding this comment

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

Can you rebase this PR on top of #392 (review) thanks 🙏

assertTrue(refNames.contains("main"));
}
}

Copy link
Collaborator

@sumedhsakdeo sumedhsakdeo Nov 9, 2025

Choose a reason for hiding this comment

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

Can we add a test-case here that enables MOR on table, and then updates/deletes rows in the main branch, then test two-scenarios, commit conflict that cannot be retried because main has received new updates and cherry pick that goes through because main has not received new updates.

Copy link
Collaborator

@sumedhsakdeo sumedhsakdeo left a comment

Choose a reason for hiding this comment

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

We should find a way to reuse some of the tests in iceberg repo to work against our OH catalog implementation for complete confidence. I found the following test cases that may be relevant.

We could either leverage the test modules from linkedin/iceberg in linkedin/openhouse, or use OpenHouse catalog in linkedin/iceberg.

https://github.com/linkedin/iceberg/blob/openhouse-1.5.0/core/src/test/java/org/apache/iceberg/TestWapWorkflow.java
https://github.com/linkedin/iceberg/blob/openhouse-1.5.0/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionedWritesToWapBranch.java
https://github.com/linkedin/iceberg/blob/openhouse-1.5.0/core/src/test/java/org/apache/iceberg/TestSnapshotManager.java
https://github.com/linkedin/iceberg/blob/openhouse-1.5.0/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestBranchDDL.java
https://github.com/linkedin/iceberg/blob/openhouse-1.5.0/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionedWritesToBranch.java
https://github.com/linkedin/iceberg/blob/openhouse-1.5.0/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestPartitionedWritesToWapBranch.java
https://github.com/linkedin/iceberg/blob/openhouse-1.5.0/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestFastForwardBranchProcedure.java
https://github.com/linkedin/iceberg/blob/openhouse-1.5.0/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestTagDDL.java
https://github.com/linkedin/iceberg/blob/openhouse-1.5.0/spark/v3.5/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestCherrypickSnapshotProcedure.java

.sql("SELECT * FROM " + tableName + " VERSION AS OF 'feature_a'")
.collectAsList()
.size()); // feature-a unchanged

Copy link
Collaborator

Choose a reason for hiding this comment

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

add a test for select from wap snapshot?

"Main branch should still have 1 row (staged WAP not visible)");

// ===== SELECTIVE WAP PUBLISHING =====

Copy link
Collaborator

Choose a reason for hiding this comment

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

swap the publish order here, wap3 before wap2, then do a time-travel query see if the cherry pick order is maintained.

.collectAsList();
String wap2SnapshotId = String.valueOf(wap2Snapshots.get(0).getLong(0));
spark.sql(
"CALL openhouse.system.cherrypick_snapshot('"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any particular reason why you picked cherrypick_snapshot over publish_changes? What is the difference? Should we have a test for both?

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.

3 participants