-
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
Ttl schema #422
Ttl schema #422
Conversation
Can one of the admins verify this patch? |
66386fc
to
7e14da3
Compare
87669de
to
9ecfda7
Compare
Refactor and rebase master, please review code, thx. |
src/dataman/ResultSchemaProvider.cpp
Outdated
@@ -46,7 +46,8 @@ bool ResultSchemaProvider::ResultSchemaField::isValid() const { | |||
* | |||
**********************************/ | |||
ResultSchemaProvider::ResultSchemaProvider(Schema schema) | |||
: columns_(std::move(schema.get_columns())) { | |||
: columns_(std::move(schema.get_columns())), | |||
schemaProp_(std::move(schema.get_schema_prop())) { |
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.
Result schema is used for Result. Please don't put schema props here.
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.
@dangleptr , 👍👍
Yeah, in the initial design, desc tag/edge not only displays column information, but also shows schema attributes.
This way is now abandoned. The desc tag/edge only displays column information.
Show create tag/edge not only displays column information, but also shows the schema attributes.(PR #496 )
Today I am going to update this PR, thx.
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.
@dangleptr , ResultSchemaProvider used in storage is used to read filter. So we need schema props in ResultSchemaProvider
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.
Use NebulaSchemaProvider, ResultSchemaProvider is designed for result.
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.
👍,Thank you very much for the guidance offline. I will fix it.
31d9578
to
2cde598
Compare
Fix and rebase master. please code review again, thx |
b9174fe
to
c0d7504
Compare
Fix conflicts and rebase master. please code review again. |
src/graph/test/SchemaTest.cpp
Outdated
auto code = client->execute(query, resp); | ||
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); | ||
} | ||
sleep(FLAGS_load_data_interval_secs + 1); |
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.
Delete all sleep after rebase master
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.
Good catch. 👍
I will strengthen the review work in the future, and I apologize here.
@@ -66,8 +66,14 @@ struct ColumnDef { | |||
2: required ValueType type, | |||
} | |||
|
|||
struct SchemaProp { |
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.
CREATE TAG person(name string) ttl_duration = 100, ttl_col = name
Here, the name
call option, ttl_duration
call property,but in INSERT VERTEX (name)
the name
call property. Please call it 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.
Good point.
CREATE TAG person(name string) ttl_duration = 100, ttl_col = name
in parser.yy like
KW_CREATE KW_TAG name_label L_PAREN column_spec_list R_PAREN create_schema_prop_list
in meta.thrift like
struct CreateTagReq {
1: common.GraphSpaceID space_id,
2: string tag_name,
3: common.Schema schema,
}
struct Schema {
1: list<ColumnDef> columns,
2: SchemaProp schema_prop,
}
struct ColumnDef {
1: required string name,
2: required ValueType type,
}
struct SchemaProp {
1: i64 ttl_duration,
2: string ttl_col,
}
Here, the name
is a ColumnDef
in Schema.columns
, ttl_duration
is in SchemaProp
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.
INSERT VERTEX (name)
in parser.yy like
insert_vertex_sentence
: KW_INSERT KW_VERTEX vertex_tag_list KW_VALUES vertex_row_list
vertex_tag_item
: name_label L_PAREN prop_list R_PAREN
in storage.thrift
struct AddVerticesRequest {
1: common.GraphSpaceID space_id,
// partId => vertices
2: map<common.PartitionID, list<Vertex>>(cpp.template = "std::unordered_map") parts,
// If true, it equals an upsert operation.
3: bool overwritable,
}
struct Vertex {
1: common.VertexID id,
2: list<Tag> tags,
}
struct Tag {
1: common.TagID tag_id,
2: binary props,
}
Here props
in Tag
struct contains schema and the column value to insert.
so name
in INSERT VERTEX (name)
is in schema of props
and is also a ColumnDef in Schema.columns
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.
By the way, in nGQL
ALTER TAG woman
Drop (name, email)
ttl_duration = 200
In meta.thrift like:
struct AlterTagReq {
1: common.GraphSpaceID space_id,
2: string tag_name,
3: list<AlterSchemaOption> schema_options,
4: list<AlterSchemaProp> schema_props,
}
struct AlterSchemaOption {
1: AlterSchemaOptionType type,
2: common.Schema schema,
}
Drop (name, email)
is called a AlterSchemaOption, but name
is also a ColumnDef
in AlterSchemaOption.schema.columns
src/meta/MetaServiceUtils.cpp
Outdated
} | ||
} | ||
|
||
Status MetaServiceUtils::checkSchemaTTLProp(nebula::cpp2::SchemaProp& prop) { |
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 it makes more sense to put this check on graphd
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.
Good, 👍
I will fixed
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 carefully thought about it.
Here checkSchemaTTLProp
uses alter tag/edge
sentence.
checkSchemaTTLProp
can be executed after the schema of the alter statement is updated in meta.
feaf147
to
4f687cf
Compare
Fix laura-ding's comments and rebase master, please review again. |
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.
Well done~ The PR LGTM now. Thanks for your effort! @steppenwolfyuetong
@steppenwolfyuetong please modify nGQL.md to address TTL usage. Or at least give explanations at the beginning of this pr, and we can help to improve nGQL.md |
Yeah, This Pr is just the second part of the ttl feature. Please accept it first. thx |
@@ -0,0 +1,44 @@ | |||
/* Copyright (c) 2019 vesoft inc. All rights reserved. |
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.
any tests to cover this class and all the public functions ?
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.
create tag/edge and alter tag/edge use these public functions.
|
||
|
||
// static | ||
Status SchemaHelper::setTTLDuration(SchemaPropItem* schemaProp, nebula::cpp2::Schema& schema) { |
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 to const schemaProp if no modifications.
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 original pointer type here is non-const
for (auto& col : schema.columns) { | ||
if (col.name == ttlColName) { | ||
// Only integer columns and timestamp columns can be used as ttl_col | ||
if (col.type.type != nebula::cpp2::SupportedType::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.
why only int & timestamp?
why not double and datetime? datetime is common. at least add a TODO to mark this.
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.
Types that can be converted to 64-bit integers should be.
double type can not be.
If the datetime type is stored according to the timestamp, here I add a TODO
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
std::string query = "DESCRIBE TAG person"; | ||
auto code = client->execute(query, resp); | ||
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code); | ||
std::vector<uniform_tuple_t<std::string, 2>> expected{ |
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.
this expected result looks duplicated (to check unchanged). U can make it outside to be seen hereafter. maybe call it another name, e.g., rawExpected.
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.
tag/edge schema properies use show create tag/edge
to display, not use desc tag/edge
.
Here I add a TODO
I will improve it in PR ” Support show create tag/edge xxx, show create space xxx SQL ” #496
cpp2::ExecutionResponse resp; | ||
std::string query = "CREATE EDGE woman(name string, email string, " | ||
"age int, gender string, row_timestamp timestamp)" | ||
"ttl_duration = -100, ttl_col = row_timestamp"; |
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.
try to test ttl_duration = 0 // what do u want if ttl == 0?
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.
Yeah, ttl_duration default value is 0.
< 0 represens infinity
@@ -537,6 +537,9 @@ create_schema_prop_list | |||
|
|||
create_schema_prop_item | |||
: KW_TTL_DURATION ASSIGN INTEGER { | |||
if ($3 < 0) { |
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.
what's your desgin for ttl == 0?
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.
< = 0 represents infinity.
so <0
to =0
Here I add a comment.
src/meta/MetaServiceUtils.cpp
Outdated
cols.erase(it); | ||
return cpp2::ErrorCode::SUCCEEDED; | ||
} else { | ||
LOG(WARNING) << "Column cant't be dropped, a TTL attribute on it : " |
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.
can't
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.
👍👍👍
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'm generally OK with this pr, with a few questions.
if (colName == it->get_name()) { | ||
// Check if there is a TTL on the column to be deleted | ||
if (!prop.get_ttl_col() || | ||
(prop.get_ttl_col() && (*prop.get_ttl_col() != colName))) { |
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'm a bit curious about *prop.get_ttl_col() != colName
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.
What do you want to know
src/meta/MetaServiceUtils.cpp
Outdated
} | ||
|
||
// Disable implicit TTL mode | ||
if ((schemaProp.get_ttl_duration() && (*schemaProp.get_ttl_duration() !=0)) && |
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.
space
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.
good catch
e69f80c
jenkins go |
Unit testing passed. |
1 similar comment
Unit testing passed. |
Fix comments |
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.
GREAT
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
Unit testing passed. |
* support time to live alter tag/edge drop column, and the column to be delete is as TTL column * improve unreserved keywords feature * address laura-ding's comment * address dangleptr's comment * address dangleptr's comment * In AlterTagReq/AlterEdgeReq discards AlterSchemaProp, using SchemaProp * address comments * address dangleptr's comments * address comments
* support time to live alter tag/edge drop column, and the column to be delete is as TTL column * improve unreserved keywords feature * address laura-ding's comment * address dangleptr's comment * address dangleptr's comment * In AlterTagReq/AlterEdgeReq discards AlterSchemaProp, using SchemaProp * address comments * address dangleptr's comments * address comments
* add insert vertex only parser add insert vertex only validator fix grammar adjust insert vertex parser * add test * format * merge master * modify parser * add fetch test * format * fix fetch vertex without tag error Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com> Co-authored-by: hs.zhang <22708345+cangfengzhs@users.noreply.github.com> Co-authored-by: Sophie <84560950+Sophie-Xie@users.noreply.github.com>
TTL feature in syntax and meta schema.
Contains the following content:
show create tag/edge in PR #439