-
Notifications
You must be signed in to change notification settings - Fork 44
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
Conversation
🎊 PR Preview 070d6ea has been successfully built and deployed to https://alibaba-graphar-build-pr-136.surge.sh ![]() 🤖 By surge-preview |
c27905b
to
8dedfb9
Compare
cpp/src/arrow_chunk_writer.cc
Outdated
" not found"); | ||
auto field = schema->field(indice); | ||
if (DataType::ArrowDataTypeToDataType(field->type()) != property.type) | ||
return Status::TypeError("invalid data type for property: " + |
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.
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)
cpp/src/arrow_chunk_writer.cc
Outdated
return Status::OK(); | ||
// weak validate | ||
if (!edge_info_.ContainAdjList(adj_list_type_)) | ||
return Status::InvalidOperation("invalid adj list type"); |
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.
Ditto, error msg should be " The adj list type: xxx is not exist in edge info"
cpp/src/arrow_chunk_writer.cc
Outdated
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"); |
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.
Ditto, "The adj list type has to be ordered_by_source or ordered_by_dest, but got xxx"
cpp/src/arrow_chunk_writer.cc
Outdated
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(); |
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.
Ditto
cpp/src/arrow_chunk_writer.cc
Outdated
return Status::OutOfRange(); | ||
if (adj_list_type_ == AdjListType::ordered_by_dest && | ||
input_table->num_rows() > edge_info_.GetDstChunkSize() + 1) | ||
return Status::OutOfRange(); |
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.
Ditto
cpp/src/arrow_chunk_writer.cc
Outdated
auto schema = input_table->schema(); | ||
int index = schema->GetFieldIndex(GeneralParams::kOffsetCol); | ||
if (index == -1) | ||
return Status::InvalidOperation("offsets not provided"); |
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.
"offset column not provided"
cpp/src/arrow_chunk_writer.cc
Outdated
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"); |
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 data type of offset offset column should be INT64, but got "
cpp/src/arrow_chunk_writer.cc
Outdated
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"); |
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.
Ditto
cpp/src/arrow_chunk_writer.cc
Outdated
" not found"); | ||
auto field = schema->field(indice); | ||
if (DataType::ArrowDataTypeToDataType(field->type()) != property.type) | ||
return Status::TypeError("invalid data type for property: " + |
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.
Ditto
cpp/src/arrow_chunk_writer.cc
Outdated
if (index == -1) | ||
return Status::InvalidOperation("offsets not provided"); | ||
indices.push_back(index); | ||
auto in_table = input_table->SelectColumns(indices).ValueOrDie(); |
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.
Make it simple and elegance
GAR_ASSIGN_OR_RAISE(auto in_table, input_table->SelectColumns({index});
8dedfb9
to
fb903e2
Compare
@acezen, thanks for your suggestions, I have added more error informations when validating. |
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
fb903e2
to
070d6ea
Compare
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 applyChecklist
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.Further comments
related to issue #127