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

[Improvement][C++] Add validation for data types for writers in C++ library #136

Merged
merged 7 commits into from
Apr 18, 2023

Conversation

lixueclaire
Copy link
Contributor

Proposed changes

This update includes the implementation of various validation levels in the GraphAr C++ SDK writers. These new validation levels could ensure the consistency of data types between the data and meta info before being written.

Types of changes

What types of changes does your code introduce to GraphAr?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

related to issue #127

@github-actions
Copy link

github-actions bot commented Apr 14, 2023

🎊 PR Preview 070d6ea has been successfully built and deployed to https://alibaba-graphar-build-pr-136.surge.sh

🤖 By surge-preview

@lixueclaire lixueclaire changed the title [WIP][Improvement][C++] Add validation for data types in VertexPropertyWriter [WIP][Improvement][C++] Add validation for data types for writers in C++ library Apr 14, 2023
@lixueclaire lixueclaire changed the title [WIP][Improvement][C++] Add validation for data types for writers in C++ library [Improvement][C++] Add validation for data types for writers in C++ library Apr 14, 2023
@lixueclaire lixueclaire requested a review from acezen April 17, 2023 01:34
@lixueclaire lixueclaire force-pushed the 127-validate-writer branch 2 times, most recently from c27905b to 8dedfb9 Compare April 18, 2023 01:27
" not found");
auto field = schema->field(indice);
if (DataType::ArrowDataTypeToDataType(field->type()) != property.type)
return Status::TypeError("invalid data type for property: " +
Copy link
Contributor

Choose a reason for hiding this comment

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

We can add more error informations like

std::string err_msg = "Invalid data type for property: " + property.name + " define as " + property.type.ToTypeName() + " but got " + DataType::ArrowDataTypeToDataType(field->type()).TypeName;
return Status::TypeError(err_msg)

return Status::OK();
// weak validate
if (!edge_info_.ContainAdjList(adj_list_type_))
return Status::InvalidOperation("invalid adj list type");
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto, error msg should be " The adj list type: xxx is not exist in edge info"

return Status::InvalidOperation("invalid adj list type");
if (adj_list_type_ != AdjListType::ordered_by_source &&
adj_list_type_ != AdjListType::ordered_by_dest)
return Status::InvalidOperation("invalid adj list type");
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto, "The adj list type has to be ordered_by_source or ordered_by_dest, but got xxx"

return Status::InvalidOperation("invalid adj list type");
if (adj_list_type_ == AdjListType::ordered_by_source &&
input_table->num_rows() > edge_info_.GetSrcChunkSize() + 1)
return Status::OutOfRange();
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

return Status::OutOfRange();
if (adj_list_type_ == AdjListType::ordered_by_dest &&
input_table->num_rows() > edge_info_.GetDstChunkSize() + 1)
return Status::OutOfRange();
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

auto schema = input_table->schema();
int index = schema->GetFieldIndex(GeneralParams::kOffsetCol);
if (index == -1)
return Status::InvalidOperation("offsets not provided");
Copy link
Contributor

Choose a reason for hiding this comment

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

"offset column not provided"

return Status::InvalidOperation("offsets not provided");
auto field = schema->field(index);
if (field->type()->id() != arrow::Type::INT64)
return Status::TypeError("invalid data type for offsets");
Copy link
Contributor

Choose a reason for hiding this comment

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

"The data type of offset offset column should be INT64, but got "

return Status::InvalidOperation("destinations not provided");
field = schema->field(index);
if (field->type()->id() != arrow::Type::INT64)
return Status::TypeError("invalid data type for destinations");
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

" not found");
auto field = schema->field(indice);
if (DataType::ArrowDataTypeToDataType(field->type()) != property.type)
return Status::TypeError("invalid data type for property: " +
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

if (index == -1)
return Status::InvalidOperation("offsets not provided");
indices.push_back(index);
auto in_table = input_table->SelectColumns(indices).ValueOrDie();
Copy link
Contributor

@acezen acezen Apr 18, 2023

Choose a reason for hiding this comment

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

Make it simple and elegance

GAR_ASSIGN_OR_RAISE(auto in_table, input_table->SelectColumns({index});

@lixueclaire lixueclaire force-pushed the 127-validate-writer branch from 8dedfb9 to fb903e2 Compare April 18, 2023 05:53
@lixueclaire
Copy link
Contributor Author

@acezen, thanks for your suggestions, I have added more error informations when validating.

Copy link
Contributor

@acezen acezen left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants