You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "kumarpritam863 (via GitHub)" <gi...@apache.org> on 2025/11/27 03:52:09 UTC
[PR] Add start and end offset for each source topic partition in iceberg snapshot as a property [iceberg]
kumarpritam863 opened a new pull request, #14701:
URL: https://github.com/apache/iceberg/pull/14701
## Summary
This PR enhances the Kafka Connect sink to track offset ranges (start and end offsets) for each topic partition, providing better traceability of which source data was included in each Iceberg
snapshot.
## Motivation
Previously, the connector only tracked a single offset value per partition, which represented the next offset to consume. This made it difficult to determine the exact range of data that was
committed in a particular snapshot. By tracking both start and end offsets, we can now:
1. Precisely identify the range of Kafka messages included in each Iceberg snapshot
2. Improve debugging and data lineage capabilities
3. Enable better auditing and compliance tracking
4. Facilitate data recovery and reprocessing scenarios
5. Also this will enable switching to exact topic partition for Flink jobs if running in hybrid mode with model of iceberg -> kafka
## Changes
### Core Data Models
**`TopicPartitionOffset` class:**
- Changed from single `offset` field to `startOffset` and `endOffset` fields
- Updated Iceberg schema to include both offset fields
- Field IDs: `START_OFFSET = 10_702`, `END_OFFSET = 10_703`, `TIMESTAMP = 10_704`
- Added getter methods: `startOffset()` and `endOffset()`
**`Offset` class:**
- Modified to track both `startOffset` and `endOffset` instead of a single offset
- Added backward compatibility method `offset()` that returns `endOffset`
- Updated constructor signature: `Offset(Long startOffset, Long endOffset, OffsetDateTime timestamp)`
### Offset Tracking
**`SinkWriter` class:**
- Enhanced `save()` method to track offset ranges per partition
- For the first record in a partition: `startOffset = currentOffset`, `endOffset = currentOffset + 1`
- For subsequent records: preserves original `startOffset`, updates `endOffset = currentOffset + 1`
- Ensures accurate range tracking across multiple records in the same commit cycle
**`Worker` class:**
- Updated to pass both `startOffset` and `endOffset` when creating `TopicPartitionOffset` objects
### Snapshot Metadata
**`CommitState` class:**
- Added `topicPartitionOffsets()` method to extract all topic partition offsets from ready buffer
- Returns complete offset information for the current commit
**`Coordinator` class:**
- Added new snapshot property: `kafka.connect.topic-partition-offsets`
- Implemented `topicPartitionOffsetsToJson()` to serialize offset ranges to JSON
- JSON format includes: `topic`, `partition`, `startOffset`, `endOffset`, and `timestamp` for each partition
- Updated `commitToTable()` to store topic partition offsets in both append and delta operations
### Example Snapshot Metadata
After this change, Iceberg snapshots will include metadata like:
```json
{
"kafka.connect.topic-partition-offsets": [
{
"topic": "events",
"partition": 0,
"startOffset": 100,
"endOffset": 250,
"timestamp": "2024-01-15T10:30:00Z"
},
{
"topic": "events",
"partition": 1,
"startOffset": 50,
"endOffset": 175,
"timestamp": "2024-01-15T10:30:05Z"
}
]
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Add start and end offset for each source topic partition in iceberg snapshot as a property [iceberg]
Posted by "kumarpritam863 (via GitHub)" <gi...@apache.org>.
kumarpritam863 commented on PR #14701:
URL: https://github.com/apache/iceberg/pull/14701#issuecomment-3584099137
@bryanck can you please review.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Add start and end offset for each source topic partition in iceberg snapshot as a property [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #14701:
URL: https://github.com/apache/iceberg/pull/14701#issuecomment-3694321660
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Add start and end offset for each source topic partition in iceberg snapshot as a property [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #14701:
URL: https://github.com/apache/iceberg/pull/14701#issuecomment-3707474776
This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Add start and end offset for each source topic partition in iceberg snapshot as a property [iceberg]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #14701: Add start and end offset for each source topic partition in iceberg snapshot as a property
URL: https://github.com/apache/iceberg/pull/14701
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org