Skip to content
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

Fix if-not-exists behavior of create index statements #4705

Merged
merged 4 commits into from
Oct 13, 2022

Conversation

czpmango
Copy link
Contributor

@czpmango czpmango commented Oct 10, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

#4665

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • N/A

Affects:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

ex. Fixed the bug .....

@czpmango czpmango added ready-for-testing PR: ready for the CI test ready for review labels Oct 10, 2022
@czpmango czpmango requested a review from Aiee October 10, 2022 10:18
@czpmango czpmango added ready-for-testing PR: ready for the CI test and removed ready-for-testing PR: ready for the CI test labels Oct 11, 2022
@czpmango czpmango requested review from panda-sheep, critical27 and a team October 11, 2022 02:40
resp_.code_ref() = nebula::cpp2::ErrorCode::E_EXISTED;
if (ifNotExists) {
resp_.code_ref() = nebula::cpp2::ErrorCode::SUCCEEDED;
cpp2::ID thriftID;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use tools like resp_.id_ref() = to(edgeIndex, EntryType::INDEX); ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just extract the id from the index item.

cpp2::ID thriftID;
// Fill index id to avoid broken promise
thriftID.index_id_ref() = item.get_index_id();
resp_.id_ref() = thriftID;
Copy link
Contributor

@panda-sheep panda-sheep Oct 11, 2022

Choose a reason for hiding this comment

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

It feels a little weird this way

  1. The first ifNotExists in line 45 is to judge whether the index name exists or not.

2 This place is to judge whether there are other indexes that contain this fields
for example

create edge e(a int, b int);
create edge index e_index on e(a, b)
create edge index if not exists e_index_2 on e(a);

When execute create edge index if not exists e_index_2 on e(a); ,this returns a creation index success and returns the indexId of the first index.
There is actually only one index e_index

Copy link
Contributor

Choose a reason for hiding this comment

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

It shows that the index creation is successful, but when show, the index name does not exist

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, this is the point just as you said.
IMO, index name is a redundant design.
A better syntax might be this:

create edge index on e(a);
create edge index if not exists on e(a);
rebuild edge index on e(a);

In this way, the implementation layer does not need to verify the index name(line 45).
Considering compatibility, this pr is not going to do major refactoring.

Copy link
Contributor

Choose a reason for hiding this comment

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

@czpmango @MuYiYong How is our GQL version index implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should try to avoid similar problems in GQL version.

Copy link
Contributor

Choose a reason for hiding this comment

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

5.0 index design needs to consider this problem, thx @MuYiYong

@codecov-commenter
Copy link

Codecov Report

Base: 84.69% // Head: 84.71% // Increases project coverage by +0.02% 🎉

Coverage data is based on head (4ec0231) compared to base (d67cc4b).
Patch coverage: 98.73% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4705      +/-   ##
==========================================
+ Coverage   84.69%   84.71%   +0.02%     
==========================================
  Files        1358     1358              
  Lines      135996   136035      +39     
==========================================
+ Hits       115185   115247      +62     
+ Misses      20811    20788      -23     
Impacted Files Coverage Δ
src/graph/executor/query/GetDstBySrcExecutor.h 100.00% <ø> (ø)
src/graph/planner/ngql/GoPlanner.h 100.00% <ø> (ø)
src/mock/MockData.cpp 96.01% <66.66%> (ø)
src/graph/context/Iterator.cpp 86.74% <100.00%> (-0.42%) ⬇️
src/graph/context/test/IteratorTest.cpp 100.00% <100.00%> (ø)
src/graph/planner/ngql/GoPlanner.cpp 99.33% <100.00%> (+0.49%) ⬆️
src/graph/visitor/DeducePropsVisitor.h 100.00% <100.00%> (ø)
...meta/processors/index/CreateEdgeIndexProcessor.cpp 71.95% <100.00%> (+1.06%) ⬆️
.../meta/processors/index/CreateTagIndexProcessor.cpp 71.77% <100.00%> (+1.07%) ⬆️
src/storage/CommonUtils.cpp 96.77% <100.00%> (ø)
... and 45 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@critical27 critical27 merged commit ab54111 into vesoft-inc:master Oct 13, 2022
@Sophie-Xie Sophie-Xie added the cherry-pick-v3.3 PR: need cherry-pick to this version label Oct 13, 2022
Sophie-Xie added a commit that referenced this pull request Oct 13, 2022
Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
Co-authored-by: Doodle <13706157+critical27@users.noreply.github.com>
Sophie-Xie added a commit that referenced this pull request Oct 13, 2022
* Use vertex key only when use_vertex_key is on (#4716)

* Revert "insert vertex key when only vertex and flag is set (#4685)"

This reverts commit fff82a6.

* Revert "only write vertex key when flag is set or explictly insert vertex (#4680)"

This reverts commit a5bed33.

* Revert "fix bug (#4675)"

This reverts commit cccc014.

* Revert "Rollback vertex key (#4629)"

This reverts commit 545137a.

* wtf

* tck format

* fix job status when all finished (#4717)

* fix job name from zone balance to data balance

* address wenhui's comment

* fix create index if not exists behavior (#4705)

Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
Co-authored-by: Doodle <13706157+critical27@users.noreply.github.com>

Co-authored-by: Doodle <13706157+critical27@users.noreply.github.com>
Co-authored-by: Alex Xing <90179377+SuperYoko@users.noreply.github.com>
Co-authored-by: kyle.cao <kyle.cao@vesoft.com>
@jinyingsunny
Copy link

checked on 3.3-rc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-v3.3 PR: need cherry-pick to this version ready for review ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants