Skip to content

Core: Fix locationProvider implementation for SerializableTable - #12564

Closed
przemekd wants to merge 7 commits into
apache:mainfrom
przemekd:main
Closed

przemekd wants to merge 7 commits into
apache:mainfrom
przemekd:main

Conversation

@przemekd

@przemekd przemekd commented Mar 18, 2025 •

Copy link
Copy Markdown
Contributor

Closes #11527 in a way that does not break fixes provided by changes needed to fix #9029.

It eagerly calculates the location provider field, but wraps that into a newly implemented wrapper TryUtil.Try that only throws an error if code really needs to use that location provider. In case table needs to be read only by other processes the error is not thrown, even if there is an error with getting the location provider object.

@github-actions github-actions Bot added the core label Mar 18, 2025
@przemekd

Copy link
Copy Markdown
Contributor Author

@aokolnychyi You were reviewing #9029, could you review this one as well please?

@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale label Apr 18, 2025
@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot closed this Apr 25, 2025
@przemekd

Copy link
Copy Markdown
Contributor Author

Can it be reopened? The PR is ready to review.

import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.junit.Test;

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
import org.junit.Test;
import org.junit.jupiter.api.Test;

*
* @param <T> the type of the result
*/
public static class Try<T> implements Serializable {

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.

Instead of using a util class what do you think about adding a static helper like:

  public static <T> Try<T> capture(ThrowingSupplier<T> supplier) {
    try {
      return success(supplier.get());
    } catch (Exception e) {
      return failure(e);
    }
  }

Then usage would look like

Try<LocationProvider> lp = Try.capture(table::locationProvider);

if (lazyLocationProvider == null) {
this.lazyLocationProvider = LocationProviders.locationsFor(location, properties);
}
try {

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.

We can move this logic into the Try class as public T getOrThrow()

@@ -265,14 +267,15 @@ public EncryptionManager encryption() {

@Override
public LocationProvider locationProvider() {

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.

Can we add some tests in spark to ensure that the exception isn't thrown on instantiation but when serializableTable.locationProvider() is thrown

przemekd added a commit to przemekd/iceberg that referenced this pull request Oct 8, 2025
- Move Try class from TryUtil.java to standalone Try.java
- Update imports in SerializableTable.java and test files
- Rename TestTryUtil.java to TestTry.java
- Address reviewer feedback from PR apache#12564
- Maintain same API: Try.capture() for deferred exception handling
przemekd added a commit to przemekd/iceberg that referenced this pull request Oct 8, 2025
- Move Try class from TryUtil.java to standalone Try.java
- Update imports in SerializableTable.java and test files
- Rename TestTryUtil.java to TestTry.java
- Address reviewer feedback from PR apache#12564
- Maintain same API: Try.capture() for deferred exception handling
@przemekd

przemekd commented Oct 8, 2025

Copy link
Copy Markdown
Contributor Author

I created a new PR #14280 as this one is closed already.

huaxingao pushed a commit to huaxingao/iceberg that referenced this pull request Nov 7, 2025
huaxingao added a commit that referenced this pull request Nov 7, 2025
…ble #12564  (#14280) (#14532)

(cherry picked from commit e667f64)

Co-authored-by: przemekd <1896041+przemekd@users.noreply.github.com>
thomaschow pushed a commit to thomaschow/iceberg that referenced this pull request Jan 19, 2026
talatuyarer pushed a commit to talatuyarer/iceberg that referenced this pull request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TableOperations.locationProvider is not respected by Spark

2 participants