-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conversation
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer strict
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, good job.
It seems some tck test cases failed~ |
11cbabe
to
f4fdadd
Compare
@@ -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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
ee98b99
to
f2eb3d9
Compare
4dd6524
to
6a5f611
Compare
@wenhaocs pls fix the tck~ |
9a132be
to
b12d547
Compare
Done! |
What type of PR is this?
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
Change int8 to int16 and then back to int8
Checklist:
Tests:
Affects:
Release notes:
Please confirm whether to be reflected in release notes and how to describe: