-
Notifications
You must be signed in to change notification settings - Fork 185
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
throw error on dimension drop in schema evolution. #4958
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,9 +152,12 @@ shared_ptr<ArraySchema> ArraySchemaEvolution::evolve_schema( | |
for (auto& attr_name : attributes_to_drop_) { | ||
bool has_attr = false; | ||
throw_if_not_ok(schema->has_attribute(attr_name, &has_attr)); | ||
if (has_attr) { | ||
throw_if_not_ok(schema->drop_attribute(attr_name)); | ||
if (!has_attr) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is not quite right. The issue is with capnp deserialization. As with all input that comes in from the outside, here from the network, we need to validate inputs. We may not assume that a capnp message was generated by There's a check in |
||
throw ArraySchemaEvolutionException( | ||
"Cannot drop attribute; Input attribute name refers to a dimension " | ||
"or does not exist"); | ||
} | ||
throw_if_not_ok(schema->drop_attribute(attr_name)); | ||
} | ||
|
||
// Drop enumerations | ||
|
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 is the statement that should fail. Avoiding a failure here only defers detection of the problem until later.
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.
Thanks for the comments Eric. I agree that the check should happen further up in
drop_attribute()
however the ArraySchema object (which is required for the use ofhas_attribute()
) is not available indrop_attribute()
. It is only passed as a parameter inArraySchemaEvolution::array_evolve()
in the form of thearray_uri
which is then used to create the schema objectHere is the current order:
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.
Yes, I see that now. I didn't realize the whole design was broken in this particular way.