Skip to content

feat: add URI-based commit support to Java SDK#5978

Merged
eddyxu merged 8 commits intolance-format:mainfrom
hamersaw:feature/java-transaction-api
Feb 26, 2026
Merged

feat: add URI-based commit support to Java SDK#5978
eddyxu merged 8 commits intolance-format:mainfrom
hamersaw:feature/java-transaction-api

Conversation

@hamersaw
Copy link
Copy Markdown
Contributor

@hamersaw hamersaw commented Feb 21, 2026

  • adds new CommitBuilder / Transaction classes to reflect the rust SDK (works over both Dataset and URI)
  • renames the current Transaction to SourcedTransaction to leave current Dataset based SDK intact, but internally everything now uses CommitBuilder
  • updates tests to use CommitBuilder route rather than SourcedTransaction
  • fills out SDKs to ensure full compatiblity (all fields / etc)

To create a dataset with existing fragments at a new URI:

  // 1. Write fragments to the dataset path
  FragmentMetadata fragmentMeta = testDataset.createNewFragment(20);

  // 2. Build a Transaction with Overwrite (provides schema for the new dataset)
  try (Transaction txn =
      new Transaction.Builder()
          .operation(
              Overwrite.builder()
                  .fragments(Collections.singletonList(fragmentMeta))
                  .schema(schema)
                  .build())
          .build()) {
    // 3. Commit to a URI where no dataset exists yet
    try (Dataset dataset = new CommitBuilder(datasetPath, allocator).execute(txn)) {
      assertEquals(1, dataset.version());
      assertEquals(20, dataset.countRows());
    }
  }

Closes #5969

Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
@github-actions github-actions Bot added enhancement New feature or request java labels Feb 21, 2026
@hamersaw hamersaw marked this pull request as ready for review February 24, 2026 14:02
Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
Copy link
Copy Markdown
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

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

Seems good. Have a few questions but nothing blocking.

Comment thread java/src/main/java/org/lance/CommitBuilder.java
Comment thread java/src/main/java/org/lance/Transaction.java
Comment thread java/src/main/java/org/lance/SourcedTransaction.java
…ction-api

Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
@eddyxu eddyxu merged commit c39b551 into lance-format:main Feb 26, 2026
7 checks passed
jackye1995 pushed a commit to wjones127/lance that referenced this pull request Feb 26, 2026
- adds new `CommitBuilder` / `Transaction` classes to reflect the rust
SDK (works over both Dataset and URI)
- renames the current `Transaction` to `SourcedTransaction` to leave
current Dataset based SDK intact, but internally everything now uses
`CommitBuilder`
- updates tests to use `CommitBuilder` route rather than
`SourcedTransaction`
- fills out SDKs to ensure full compatiblity (all fields / etc)

To create a dataset with existing fragments at a new URI:
```
  // 1. Write fragments to the dataset path
  FragmentMetadata fragmentMeta = testDataset.createNewFragment(20);

  // 2. Build a Transaction with Overwrite (provides schema for the new dataset)
  try (Transaction txn =
      new Transaction.Builder()
          .operation(
              Overwrite.builder()
                  .fragments(Collections.singletonList(fragmentMeta))
                  .schema(schema)
                  .build())
          .build()) {
    // 3. Commit to a URI where no dataset exists yet
    try (Dataset dataset = new CommitBuilder(datasetPath, allocator).execute(txn)) {
      assertEquals(1, dataset.version());
      assertEquals(20, dataset.countRows());
    }
  }
```

Closes lance-format#5969

---------

Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
wjones127 pushed a commit that referenced this pull request Feb 26, 2026
- adds new `CommitBuilder` / `Transaction` classes to reflect the rust
SDK (works over both Dataset and URI)
- renames the current `Transaction` to `SourcedTransaction` to leave
current Dataset based SDK intact, but internally everything now uses
`CommitBuilder`
- updates tests to use `CommitBuilder` route rather than
`SourcedTransaction`
- fills out SDKs to ensure full compatiblity (all fields / etc)

To create a dataset with existing fragments at a new URI:
```
  // 1. Write fragments to the dataset path
  FragmentMetadata fragmentMeta = testDataset.createNewFragment(20);

  // 2. Build a Transaction with Overwrite (provides schema for the new dataset)
  try (Transaction txn =
      new Transaction.Builder()
          .operation(
              Overwrite.builder()
                  .fragments(Collections.singletonList(fragmentMeta))
                  .schema(schema)
                  .build())
          .build()) {
    // 3. Commit to a URI where no dataset exists yet
    try (Dataset dataset = new CommitBuilder(datasetPath, allocator).execute(txn)) {
      assertEquals(1, dataset.version());
      assertEquals(20, dataset.countRows());
    }
  }
```

Closes #5969

---------

Signed-off-by: Daniel Rammer <hamersaw@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java - support commit transaction to create a new table

3 participants