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

Ttl schema #422

Merged
merged 10 commits into from
Jun 28, 2019
Merged

Ttl schema #422

merged 10 commits into from
Jun 28, 2019

Conversation

ayyt
Copy link
Contributor

@ayyt ayyt commented May 23, 2019

TTL feature in syntax and meta schema.
Contains the following content:

create tag/edge
alter tag/edge
show create tag/edge

describe tag/edge  only display column information, not display schema attributes.

show create tag/edge in PR #439

@nebula-community-bot
Copy link
Member

Can one of the admins verify this patch?

@ayyt ayyt force-pushed the TTL_schema branch 3 times, most recently from 66386fc to 7e14da3 Compare May 27, 2019 07:56
@ayyt ayyt force-pushed the TTL_schema branch 5 times, most recently from 87669de to 9ecfda7 Compare June 3, 2019 08:29
@ayyt
Copy link
Contributor Author

ayyt commented Jun 3, 2019

Refactor and rebase master, please review code, thx.

@@ -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())) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@ayyt
Copy link
Contributor Author

ayyt commented Jun 5, 2019

Fix and rebase master. please code review again, thx

@ayyt ayyt force-pushed the TTL_schema branch 6 times, most recently from b9174fe to c0d7504 Compare June 10, 2019 10:41
@ayyt
Copy link
Contributor Author

ayyt commented Jun 10, 2019

Fix conflicts and rebase master. please code review again.

@ayyt ayyt added the ready-for-testing PR: ready for the CI test label Jun 10, 2019
auto code = client->execute(query, resp);
ASSERT_EQ(cpp2::ErrorCode::SUCCEEDED, code);
}
sleep(FLAGS_load_data_interval_secs + 1);
Copy link
Contributor

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

Copy link
Contributor Author

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 {
Copy link
Contributor

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!

Copy link
Contributor Author

@ayyt ayyt Jun 11, 2019

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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

}
}

Status MetaServiceUtils::checkSchemaTTLProp(nebula::cpp2::SchemaProp& prop) {
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 it makes more sense to put this check on graphd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good,  👍
I will fixed

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

@ayyt ayyt force-pushed the TTL_schema branch 3 times, most recently from feaf147 to 4f687cf Compare June 12, 2019 06:54
@ayyt
Copy link
Contributor Author

ayyt commented Jun 12, 2019

Fix laura-ding's comments and rebase master, please review again.

dangleptr
dangleptr previously approved these changes Jun 27, 2019
Copy link
Contributor

@dangleptr dangleptr left a 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

@whitewum
Copy link
Contributor

whitewum commented Jun 27, 2019

@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
And please add more tests in the graph layer.

@ayyt
Copy link
Contributor Author

ayyt commented Jun 27, 2019

@steppenwolfyuetong please modify nGQL.md to address TTL usage. Or at least give explainations 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.
I want to update the nGQL.md when the TTL feature is completed, that is, when the Ttl read filter #478 PR is submitted. WDYT?

Please accept it first. thx

@@ -0,0 +1,44 @@
/* Copyright (c) 2019 vesoft inc. All rights reserved.
Copy link
Contributor

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 ?

Copy link
Contributor Author

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) {
Copy link
Contributor

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.

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 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 &&
Copy link
Contributor

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.

Copy link
Contributor Author

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

laura-ding
laura-ding previously approved these changes Jun 27, 2019
Copy link
Contributor

@laura-ding laura-ding left a 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{
Copy link
Contributor

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.

Copy link
Contributor Author

@ayyt ayyt Jun 27, 2019

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";
Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

cols.erase(it);
return cpp2::ErrorCode::SUCCEEDED;
} else {
LOG(WARNING) << "Column cant't be dropped, a TTL attribute on it : "
Copy link
Contributor

Choose a reason for hiding this comment

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

can't

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍👍👍

whitewum
whitewum previously approved these changes Jun 27, 2019
Copy link
Contributor

@whitewum whitewum left a 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))) {
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 a bit curious about *prop.get_ttl_col() != colName

Copy link
Contributor Author

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

}

// Disable implicit TTL mode
if ((schemaProp.get_ttl_duration() && (*schemaProp.get_ttl_duration() !=0)) &&
Copy link
Contributor

Choose a reason for hiding this comment

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

space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch

@ayyt ayyt dismissed stale reviews from whitewum, laura-ding, and dangleptr via e69f80c June 27, 2019 09:52
@ayyt
Copy link
Contributor Author

ayyt commented Jun 27, 2019

jenkins go

@nebula-community-bot
Copy link
Member

Unit testing passed.

1 similar comment
@nebula-community-bot
Copy link
Member

Unit testing passed.

@ayyt
Copy link
Contributor Author

ayyt commented Jun 27, 2019

Fix comments

Copy link
Contributor

@whitewum whitewum left a comment

Choose a reason for hiding this comment

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

GREAT

Copy link
Contributor

@laura-ding laura-ding left a comment

Choose a reason for hiding this comment

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

LGTM

@nebula-community-bot
Copy link
Member

Unit testing passed.

@dangleptr dangleptr merged commit 51e81a7 into vesoft-inc:master Jun 28, 2019
@ayyt ayyt deleted the TTL_schema branch June 28, 2019 07:42
yixinglu pushed a commit to yixinglu/nebula that referenced this pull request Feb 16, 2020
* 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
@AmberMoe AmberMoe self-assigned this Feb 17, 2020
tong-hao pushed a commit to tong-hao/nebula that referenced this pull request Jun 1, 2021
* 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
yixinglu pushed a commit to yixinglu/nebula that referenced this pull request Mar 21, 2022
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants