-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Feature] Support InPredicate in delete statement #4006
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
Conversation
|
for #4008 |
|
In fact, we are also trying to implement a batch delete function that can support the deletion of a large number of specified keys (including specifying multiple values in inPredicate) In your current implementation, if there are too many values in InPredicate (for example, tens of thousands), then each column must be looped through tens of thousands of conditions during query, which may be inefficient. Maybe you can discuss it with @yangzhg about it. |
fe/fe-core/src/main/java/org/apache/doris/analysis/DeleteStmt.java
Outdated
Show resolved
Hide resolved
fe/fe-core/src/main/java/org/apache/doris/analysis/DeleteStmt.java
Outdated
Show resolved
Hide resolved
fe/fe-core/src/main/java/org/apache/doris/load/DeleteHandler.java
Outdated
Show resolved
Hide resolved
| wrapperField.release_field(); | ||
| return ret; | ||
| } | ||
| case OP_NOT_IN: { |
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.
These 2 case (OP_IN and OP_NOT_IN) looks 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.
one is "!="(line 196), the other is "=="(line 202)
be/src/olap/olap_cond.cpp
Outdated
| tcond.column_name.c_str(), operand.c_str(), op); | ||
| return res; | ||
| } | ||
| if (min_value_field == nullptr || f->cmp(min_value_field) > 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.
I am a little confused.
A->cmp(B) > 0 means A > B or A < B?
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.
my bad, I will fix it A->cmp(B) > 0 means A > B
| // valid when op is OP_IN or OP_NOT_IN | ||
| typedef std::unordered_set<const WrapperField*, FieldHash, FieldEqual> FieldSet; | ||
| FieldSet operand_set; | ||
| WrapperField* min_value_field; |
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.
Add comment to explains these 2 new fields.
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.
done
morningman
left a comment
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
|
UT failed. |
| string condition_str = construct_sub_predicates(condition); | ||
| del_pred->add_sub_predicates(condition_str); | ||
| LOG(INFO) << "store one sub-delete condition. condition=" << condition_str; | ||
| if (condition.condition_values.size() > 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.
I think it's better to check the condition.condition_op to see if this condition is InPredicate, not by the size of condition.condition_values.
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.
because inPredicate with one element to stored as BinaryPredicate which is more more light and efficient.
morningman
left a comment
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
kangkaisen
left a comment
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.
protobuf LGTM
morningman
left a comment
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
When the IN predicate in an expression contains parameters generated through CAST operations, utilizing inverted indexes may produce erroneous query results.
This PR is to add inPredicate support to delete statement, and add max_allowed_in_element_num_of_delete variable to limit element num of InPredicate in delete statement.