Skip to content

Core: Add setter for firstRowId in V4 metadata#16849

Open
gaborkaszab wants to merge 1 commit into
apache:mainfrom
gaborkaszab:main_first_row_id_setter
Open

Core: Add setter for firstRowId in V4 metadata#16849
gaborkaszab wants to merge 1 commit into
apache:mainfrom
gaborkaszab:main_first_row_id_setter

Conversation

@gaborkaszab

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions Bot added the core label Jun 17, 2026
@gaborkaszab

Copy link
Copy Markdown
Contributor Author

Currently, there is no mechanism to set Tracking.firstRowId. Following the PR for Tracking builder, it was commented that setting firstRowId shouldn't be through the builder but via inheritance.
This PR adds a simple setter function that can be used for this. If I understand correctly, it wouldn't suite inheritFrom(manifestTracking) because it's not a direct inheritance, but based calculated based on other manifest entries that has null firstRowId + the manifest's firstRowId.

@gaborkaszab

Copy link
Copy Markdown
Contributor Author

}

void setFirstRowId(Long newFirstRowId) {
Preconditions.checkArgument(newFirstRowId != null, "Invalid first row ID: null");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just make the parameter long since it's required anyway?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 to make the parameter to long.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! done


void setFirstRowId(Long newFirstRowId) {
Preconditions.checkArgument(newFirstRowId != null, "Invalid first row ID: null");
Preconditions.checkArgument(newFirstRowId >= 0, "Invalid first row ID: negative");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Preconditions.checkArgument(newFirstRowId >= 0, "Invalid first row ID: negative");
Preconditions.checkArgument(
newFirstRowId >= 0, "Invalid first row ID: %s (must be >= 0)", newFirstRowId);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thx, done

}

void setFirstRowId(Long newFirstRowId) {
Preconditions.checkArgument(newFirstRowId != null, "Invalid first row ID: null");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1 to make the parameter to long.

}

@Test
public void testSettingFirstRowId() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about adding a test case for setFirstRowId(0L) to demonstrate the boundary of the >= 0 check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed one of the tests to use zero for input. Thx

@gaborkaszab gaborkaszab force-pushed the main_first_row_id_setter branch from fe964f0 to a0b0ddd Compare June 18, 2026 09:50

@gaborkaszab gaborkaszab left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking a look! I addressed all the comments. Additionally, there are 2 extra modifications I figured would make sense:

  1. Not allow to set first row id for ADDED entries. I think for these null is the desired value
  2. I also added a setter method to TrackedFileStruct for convenience. With this the user doesn't have to be aware of the actual representation being in Tracking and can simply invoke TrackedFileStruct.setFirstRowId() without knowing how it is represented internally.

Let me know what you think!

}

void setFirstRowId(Long newFirstRowId) {
Preconditions.checkArgument(newFirstRowId != null, "Invalid first row ID: null");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point! done


void setFirstRowId(Long newFirstRowId) {
Preconditions.checkArgument(newFirstRowId != null, "Invalid first row ID: null");
Preconditions.checkArgument(newFirstRowId >= 0, "Invalid first row ID: negative");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thx, done

}

@Test
public void testSettingFirstRowId() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed one of the tests to use zero for input. Thx

@gaborkaszab gaborkaszab force-pushed the main_first_row_id_setter branch from a0b0ddd to ab3b98a Compare June 18, 2026 10:02
@gaborkaszab gaborkaszab changed the title Core: Add setter for TrackingStruct.firstRowId Core: Add setter for firstRowId in V4 metadata Jun 18, 2026
@gaborkaszab gaborkaszab requested a review from anoopj June 18, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants