Skip to content

Core: Reuse ops in BaseMetastoreViewCatalog.loadView#17069

Open
thswlsqls wants to merge 1 commit into
apache:mainfrom
thswlsqls:fix/baseviewcatalog-loadview-reuse-ops
Open

Core: Reuse ops in BaseMetastoreViewCatalog.loadView#17069
thswlsqls wants to merge 1 commit into
apache:mainfrom
thswlsqls:fix/baseviewcatalog-loadview-reuse-ops

Conversation

@thswlsqls

@thswlsqls thswlsqls commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Closes #17068

Summary

  • loadView() built a ViewOperations to check existence via ops.current(), then discarded it and called newViewOps(identifier) again to construct the returned BaseView, reloading view metadata from the metastore twice per call.
  • Reuse the ops from the existence check instead of creating a second instance.
  • Matches BaseViewBuilder.create/replace in the same file and the parent BaseMetastoreCatalog.loadTable(), which already reuse ops this way.

Testing done

  • Added TestBaseMetastoreViewCatalogLoadView#loadViewReusesOpsFromExistenceCheck, asserting newViewOps is called once (was twice) per loadView().
  • ./gradlew :iceberg-core:check — passed (test + spotlessCheck + checkstyle + errorProne).
  • ./gradlew :iceberg-core:revapi — passed (backward compatible, no signature change).

AI Disclosure

  • Tool: Claude Code — used to analyze the code, implement the fix, and write the test.

loadView() created a ViewOperations to check existence via
ops.current(), then discarded it and called newViewOps(identifier)
again to build the returned BaseView, so every load reloaded view
metadata from the metastore twice. BaseViewBuilder.create/replace in
the same file, and the parent BaseMetastoreCatalog.loadTable(), all
reuse the ops instance used for the existence check. Reuse ops here
too, matching that pattern and halving the remote calls per loadView.

Generated-by: Claude Code
@github-actions github-actions Bot added the core label Jul 3, 2026
import org.apache.iceberg.types.Types;
import org.junit.jupiter.api.Test;

public class TestBaseMetastoreViewCatalogLoadView {

@nastra nastra Jul 3, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think in this particular case I would probably omit having a separate test class for this case that just verifies that newViewOps() was called a single time. The change seems fairly low-risk, but let's see what other maintainers think

@thswlsqls thswlsqls Jul 4, 2026

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.

There's no existing test class for BaseMetastoreViewCatalog itself to fold this into — only the generic ViewCatalogTests shared across catalog implementations, which doesn't fit a single-impl regression check. Happy to move it if you have a preferred home.

throw new NoSuchViewException("View does not exist: %s", identifier);
} else {
return new BaseView(newViewOps(identifier), ViewUtil.fullViewName(name(), identifier));
return new BaseView(ops, ViewUtil.fullViewName(name(), identifier));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks correct to me, thanks for spotting this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

@nastra

nastra commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

@thswlsqls the project requires AI disclosure text on the PR itself. Something like Used Claude code to generate fix + test is enough. See https://iceberg.apache.org/contribute/#guidelines-for-ai-assisted-contributions for some additional details. That means you should probably also do the same thing across your other PRs

@kevinjqliu

Copy link
Copy Markdown
Contributor

@thswlsqls thanks for your contributions.

I noticed that you currently have 32 PRs open, including 14 opened in the last 24 hours. That volume can make it difficult for maintainers to review carefully and can create a lot of noise in the repo.

A better way to contribute is to pick one or two focused issues, make sure you understand the changes well enough to explain them end to end, and work with reviewers on those before opening more PRs. This makes it much easier for maintainers to give useful feedback and for your contributions to move forward.

As @nastra mentioned, please also review the Iceberg guidelines for AI-assisted contributions: https://iceberg.apache.org/contribute/#guidelines-for-ai-assisted-contributions

@thswlsqls

Copy link
Copy Markdown
Contributor Author

@nastra @kevinjqliu Fair points, thanks both. I've added an AI Disclosure section to this PR's description and will do the same on my other open PRs. On pace — understood, I'll slow down and focus on getting a smaller set of these through review rather than opening more.

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.

Core: Reuse ops in BaseMetastoreViewCatalog.loadView

4 participants