Skip to content

improvement(catalogs): fix index existence check #7621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 11, 2025

Conversation

senlizishi
Copy link
Contributor

What changes were proposed in this pull request?

fix index existence check

Why are the changes needed?

Fix: #7591

Does this PR introduce any user-facing change?

No

How was this patch tested?

tests added.

@senlizishi
Copy link
Contributor Author

@justinmclean PTAL

@@ -774,7 +774,7 @@ static String addIndexDefinition(TableChange.AddIndex addIndex) {

static String deleteIndexDefinition(
JdbcTable lazyLoadTable, TableChange.DeleteIndex deleteIndex) {
if (deleteIndex.isIfExists()) {
if (!deleteIndex.isIfExists()) {
Preconditions.checkArgument(
Arrays.stream(lazyLoadTable.index())
.anyMatch(index -> index.name().equals(deleteIndex.getName())),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm puzzled that since you use !deleteIndex.isIfExists() in L777, should this place be nonMatch NOT anyMatch here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm puzzled that since you use !deleteIndex.isIfExists() in L777, should this place be nonMatch NOT anyMatch here?

Thank you for your review. My understanding is that when deleteIndex.isIfExists() is false, the code block will be entered. Next, check whether the name of any index in lazyLoadTable is the same as deleteIndex.getName(). If it is the same, it will run normally. Otherwise, it will report an Index does not exist exception. I don't know if my understanding is correct ?

Copy link
Member

Choose a reason for hiding this comment

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

My understanding is that if isIfExists returns true, then it will ignore any warnings about non-existent indexes. If it returns false, then you do want to warn about non-existent indexes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. It's my mistake.

Copy link
Member

Choose a reason for hiding this comment

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

The method doesn't have the best name, which can be a little confusing.

Copy link
Contributor

@yuqi1129 yuqi1129 left a comment

Choose a reason for hiding this comment

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

LGTM

@yuqi1129 yuqi1129 added the branch-0.9 Automatically cherry-pick commit to branch-0.9 label Jul 10, 2025
@justinmclean justinmclean merged commit 09cff79 into apache:main Jul 11, 2025
30 checks passed
github-actions bot pushed a commit that referenced this pull request Jul 11, 2025
### What changes were proposed in this pull request?

fix index existence check

### Why are the changes needed?

Fix: #7591 

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

tests added.

Co-authored-by: senlizishi <[email protected]>
@senlizishi senlizishi deleted the fix-index-exit-check branch July 11, 2025 01:51
vishnu-chalil pushed a commit to vishnu-chalil/gravitino that referenced this pull request Jul 14, 2025
### What changes were proposed in this pull request?

fix index existence check

### Why are the changes needed?

Fix: apache#7591 

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

tests added.

Co-authored-by: senlizishi <[email protected]>
hdygxsj pushed a commit to hdygxsj/gravitino that referenced this pull request Jul 15, 2025
### What changes were proposed in this pull request?

fix index existence check

### Why are the changes needed?

Fix: apache#7591 

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

tests added.

Co-authored-by: senlizishi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch-0.9 Automatically cherry-pick commit to branch-0.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] fix index existence check
3 participants