Skip to content

[Server] Pass a typed properties setter to RepositoryUtils.attachProperties - #2326

Merged
yili-db merged 1 commit into
unitycatalog:mainfrom
maharanay22:refactor-attach-properties-typed-setter
Nov 20, 2026
Merged

yili-db merged 1 commit into
unitycatalog:mainfrom
maharanay22:refactor-attach-properties-typed-setter

Conversation

@maharanay22

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

This follows up on #2319, as suggested in its review. RepositoryUtils.attachProperties looked up setProperties(Map) on the model by reflection, so a model whose properties aren't a map compiled fine and then failed at runtime, and only once the entity had property rows. That is how a function transfer failed with NoSuchMethodException before #2319, because FunctionInfo.properties is a JSON string.

Callers now pass the setter as a method reference, for example CatalogInfo::setProperties, typed as BiConsumer<T, Map<String, String>>. Passing FunctionInfo::setProperties no longer compiles, so that mistake shows up at build time. The reflection and its exception wrapping are removed. The property lookup is unchanged, and the model is still left untouched when there are no property rows, so API responses don't change. SchemaRepository.getSchema attached the properties a second time after convertFromDAO had already done it, so that redundant call is removed.

Tests

RepositoriesTest.catalogSchemaAndTableReadsAttachTheirProperties stores a catalog, a schema and a table with different properties, and checks that get, list and update for catalogs and schemas, and get and owner update for tables, return each entity's own properties. Replacing the setter with a no-op at any call site makes it fail. A scratch call passing FunctionInfo::setProperties failed server/compile with "incompatible types: invalid method reference".

build/sbt "server/testOnly io.unitycatalog.server.persist.RepositoriesTest io.unitycatalog.server.persist.OwnershipRepositoryTest io.unitycatalog.server.persist.utils.RepositoryUtilsTest" passes on H2 on Windows with JDK 17, and so do server/javafmtCheckAll and checkstyle. The change has no SQL, so MySQL and PostgreSQL run in CI.

…erties

attachProperties found setProperties(Map) by reflection, so a model whose
properties are not a Map, such as FunctionInfo, compiled and then failed at
runtime once property rows existed (the bug fixed in unitycatalog#2319). Callers now pass
the setter as a method reference, so an incompatible model fails to compile.
The property lookup and the skip when there are no rows are unchanged.

Add a RepositoriesTest case that checks catalog, schema and table get, list
and update responses carry each entity's stored properties.

Signed-off-by: Maha Rana Yadavalli <[email protected]>
@yili-db

yili-db commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[AI Assisted] Approving at b8dc699.

  • This is a refactor. The property lookup, the leave-unchanged-when-empty rule, and the returned instance are the same as before. The only observable change is that SchemaRepository.getSchema runs one fewer properties query; the output is unchanged.
  • All eight remaining call sites pass a typed setter, and no caller was missed. The function path no longer goes through this helper, so the #2319 failure cannot return through it.
  • Verified: the touched tests pass (48 of 48). A call that passes FunctionInfo::setProperties fails to compile, as the description says.

@yili-db
yili-db merged commit 96774e7 into unitycatalog:main Nov 20, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants