Skip to content

Commit

Permalink
fix: increase expr recursion depth to avoid parse failed (milvus-io#2…
Browse files Browse the repository at this point in the history
…9860) (milvus-io#30021)

pr: milvus-io#29860

Signed-off-by: luzhang <[email protected]>
Co-authored-by: luzhang <[email protected]>
  • Loading branch information
zhagnlu and luzhang authored Jan 16, 2024
1 parent a215fb0 commit 9f6a19c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/core/src/query/Plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ CreateRetrievePlanByExpr(const Schema& schema,
const void* serialized_expr_plan,
const int64_t size) {
proto::plan::PlanNode plan_node;
plan_node.ParseFromArray(serialized_expr_plan, size);
google::protobuf::io::ArrayInputStream array_stream(serialized_expr_plan,
size);
google::protobuf::io::CodedInputStream input_stream(&array_stream);
input_stream.SetRecursionLimit(std::numeric_limits<int32_t>::max());

auto res = plan_node.ParsePartialFromCodedStream(&input_stream);
if (!res) {
throw SegcoreError(UnexpectedError, "parse plan node proto failed");
}
return ProtoParser(schema).CreateRetrievePlan(plan_node);
}

Expand Down
18 changes: 18 additions & 0 deletions tests/python_client/testcases/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2352,6 +2352,24 @@ def test_query_using_all_types_of_default_value(self):
assert res[ct.default_bool_field_name] is False
assert res[ct.default_string_field_name] == "abc"

@pytest.mark.tags(CaseLabel.L0)
def test_query_multi_logical_exprs(self):
"""
target: test the scenario which query with many logical expressions
method: 1. create collection
3. query the expr that like: int64 == 0 || int64 == 1 ........
expected: run successfully
"""
c_name = cf.gen_unique_str(prefix)
collection_w = self.init_collection_wrap(name=c_name)
df = cf.gen_default_dataframe_data()
collection_w.insert(df)
collection_w.create_index(ct.default_float_vec_field_name, index_params=ct.default_flat_index)
collection_w.load()
multi_exprs = " || ".join(f'{default_int_field_name} == {i}' for i in range(60))
_, check_res = collection_w.query(multi_exprs, output_fields=[f'{default_int_field_name}'])
assert(check_res == True)


class TestQueryString(TestcaseBase):
"""
Expand Down

0 comments on commit 9f6a19c

Please sign in to comment.