Skip to content

Conversation

@flyrain
Copy link
Contributor

@flyrain flyrain commented Mar 3, 2025

This PR extracts several inner classes of PolarisMetastoreManager into top-level classes, improving readability and maintainability. After the refactor, the PolarisMetastoreManager interface now contains only methods, making it concise and clean. Typically, inner classes are used when their lifecycle depends on the outer class instance. However, these particular classes were independent, being used not only by service layers but also potentially by other database implementations. They are more suitable as top-level classes.

Copy link
Contributor

@dennishuo dennishuo left a comment

Choose a reason for hiding this comment

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

Generally seems like a good direction to extract all the Result classes. I don't mind too much which package, but should BaseResult be in the same package?

import org.apache.polaris.core.persistence.BaseResult;

/** a set of returned entities result */
public class EntitiesResult extends BaseResult {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to keep BaseResult in the persistence package when all the subclasses are moved in here, or should BaseResult also be moved here?

Copy link
Member

Choose a reason for hiding this comment

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

Imho, it should also be in the persistence package to be really isolated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved BaseResult to the same package. It's under the persistence package already.

Copy link
Member

Choose a reason for hiding this comment

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

👍 it looks better, thanks !

@github-project-automation github-project-automation bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Mar 3, 2025
Copy link
Contributor

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

This refactoring LGTM overall, just one minor comment.

import org.apache.polaris.core.entity.PolarisEntityType;
import org.apache.polaris.core.entity.PolarisGrantRecord;
import org.apache.polaris.core.entity.PolarisPrincipalSecrets;
import org.apache.polaris.core.persistence.dao.entity.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please expand to individual imports

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make spotless check for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the star import.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, we can add a file with something like this in it

<module name="AvoidStarImport"/> 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like spotless cannot do that, we will need a new plugin like this

  pluginManager.withPlugin('com.palantir.baseline-checkstyle') {
    checkstyle {
      toolVersion '9.3'
    }
  }

Copy link
Contributor

@singhpk234 singhpk234 left a comment

Choose a reason for hiding this comment

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

LGTM as well !

import org.apache.polaris.core.entity.PolarisPrivilege;
import org.apache.polaris.core.entity.PolarisTaskConstants;
import org.apache.polaris.core.persistence.*;
import org.apache.polaris.core.persistence.dao.entity.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

just in this case this gets missed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@flyrain
Copy link
Contributor Author

flyrain commented Mar 3, 2025

Fixed all star import introduced by this PR. Thanks @dimas-b and @singhpk234 for catching it. There are other places having star import as well. File #1100 to track it.

import org.apache.polaris.core.entity.PolarisEntitySubType;

/** the return for an entity lookup call */
public class EntityResult extends BaseResult {
Copy link
Contributor

Choose a reason for hiding this comment

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

Organizationally the change makes sense to me, but to my knowledge this is the first PR that adds the DAO / entity terminology -- potentially a little confusing when we have PolarisBaseEntity and friends.

To clarify, what is going to be the scope of this new package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, just saw your message after merging. I was trying to position dao to hold most interfaces, entity, util related to DAO layer. I'm open to any suggestions.

@flyrain flyrain merged commit 047f3ea into apache:main Mar 3, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Ready to merge to Done in Basic Kanban Board Mar 3, 2025
gh-yzou pushed a commit to gh-yzou/polaris that referenced this pull request Mar 6, 2025
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.

6 participants