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

Restrict schema type conversion #5098

Merged
merged 18 commits into from
Dec 28, 2022

Conversation

wenhaocs
Copy link
Contributor

@wenhaocs wenhaocs commented Dec 23, 2022

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

https://github.com/vesoft-inc/nebula-ent/issues/1786

Description:

We now restrict the type conversion in schema change. Only the following are allowed:
(1) fixed string -> larger fixed string
(2) fixed string -> string
(3) thinner int -> wider int
(4) float -> double
(5) no type change

All other conversions are not allowed.

E.g.,
Change string to fixed string
image
image

Change int8 to int16 and then back to int8
image

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 .....

src/meta/MetaServiceUtils.cpp Outdated Show resolved Hide resolved
if (from.get_type() == nebula::cpp2::PropertyType::FLOAT) {
return to.get_type() == nebula::cpp2::PropertyType::DOUBLE;
}
// Forbid all the other conversion, as the old data are too different from the new data.
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we forbid the type conversion from boolean to int?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Data are still correct if we allow for bool <-> int conversion. But the data before conversion and after conversion will look different. In a strict manner, we can disallow any conversion that will make data look different. Or if we are not that strict, we can allow bool <-> int conversion. Please clarify. cc. @MuYiYong @critical27

Copy link
Contributor

Choose a reason for hiding this comment

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

prefer strict

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could forbid it this version I think, it will introduce extra work in storage.

xtcyclist
xtcyclist previously approved these changes Dec 23, 2022
critical27
critical27 previously approved these changes Dec 23, 2022
Copy link
Contributor

@critical27 critical27 left a comment

Choose a reason for hiding this comment

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

LGTM, good job.

@critical27
Copy link
Contributor

It seems some tck test cases failed~

@wenhaocs wenhaocs dismissed stale reviews from critical27 and xtcyclist via f4fdadd December 25, 2022 01:14
@@ -1947,7 +2042,7 @@ TEST(ProcessorTest, AlterEdgeTest) {
cpp2::Schema changeSch;
cpp2::ColumnDef column;
column.name = "edge_0_col_10";
column.type.type_ref() = PropertyType::DOUBLE;
column.type.type_ref() = PropertyType::INT64;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that the current column type of col_10 is int64. The failure should come from changing col on ttl. So I keep the column type the same.

@@ -1947,7 +2042,7 @@ TEST(ProcessorTest, AlterEdgeTest) {
cpp2::Schema changeSch;
cpp2::ColumnDef column;
column.name = "edge_0_col_10";
column.type.type_ref() = PropertyType::DOUBLE;
column.type.type_ref() = PropertyType::INT64;
Copy link
Contributor Author

@wenhaocs wenhaocs Dec 25, 2022

Choose a reason for hiding this comment

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

Note that the current column type of col_10 is int64. The failure should come from changing col with ttl. So I keep the column type the same, to avoid the error coming from illegal column type change.

@@ -1452,7 +1454,7 @@ TEST(ProcessorTest, AlterTagTest) {
cpp2::Schema changeSch;
cpp2::ColumnDef column;
column.name = "tag_0_col_10";
column.type.type_ref() = PropertyType::DOUBLE;
column.type.type_ref() = PropertyType::INT64;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that the current column type of col_10 is int64. The failure should come from changing col with ttl. So I keep the column type the same, to avoid the error coming from illegal column type change.

@@ -340,27 +350,27 @@ Feature: TTLTest
| "player" | 'CREATE EDGE `player` (\n `id` int64 NULL,\n `name` string NULL,\n `age` int64 NULL,\n `address` string NULL,\n `score` float NULL\n) ttl_duration = 0, ttl_col = ""' |
When executing query:
"""
ALTER EDGE player change(name int), drop(name);
ALTER EDGE player change(name string), drop(name);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error should come from the intended, not from illegal type change. So here I keep type the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same for the followings.

@Sophie-Xie Sophie-Xie added the priority/hi-pri Priority: high label Dec 26, 2022
critical27
critical27 previously approved these changes Dec 26, 2022
@Sophie-Xie
Copy link
Contributor

@wenhaocs pls fix the tck~

@wenhaocs
Copy link
Contributor Author

@wenhaocs pls fix the tck~

Done!

@Sophie-Xie Sophie-Xie merged commit f519503 into vesoft-inc:master Dec 28, 2022
@Sophie-Xie Sophie-Xie added the doc affected PR: improvements or additions to documentation label Jan 12, 2023
@foesa-yang foesa-yang requested review from foesa-yang and removed request for foesa-yang January 17, 2023 06:32
@foesa-yang foesa-yang self-assigned this Jan 17, 2023
@foesa-yang
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc affected PR: improvements or additions to documentation priority/hi-pri Priority: high 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