mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 10:59:32 +08:00
enhance: Return parse expression failed error with reason (#30548)
Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>
This commit is contained in:
parent
b74673c147
commit
c863b82476
@ -417,10 +417,17 @@ func canBeCompared(left, right *ExprWithType) bool {
|
||||
return canBeComparedDataType(left.dataType, getArrayElementType(right))
|
||||
}
|
||||
|
||||
func getDataType(expr *ExprWithType) string {
|
||||
if typeutil.IsArrayType(expr.dataType) {
|
||||
return fmt.Sprintf("%s[%s]", expr.dataType, getArrayElementType(expr))
|
||||
}
|
||||
return expr.dataType.String()
|
||||
}
|
||||
|
||||
func HandleCompare(op int, left, right *ExprWithType) (*planpb.Expr, error) {
|
||||
if !canBeCompared(left, right) {
|
||||
return nil, fmt.Errorf("comparisons between %s, element_type: %s and %s elementType: %s are not supported",
|
||||
left.dataType, getArrayElementType(left), right.dataType, getArrayElementType(right))
|
||||
return nil, fmt.Errorf("comparisons between %s and %s are not supported",
|
||||
getDataType(left), getDataType(right))
|
||||
}
|
||||
|
||||
cmpOp := cmpOpMap[op]
|
||||
|
@ -302,7 +302,7 @@ func (dr *deleteRunner) Init(ctx context.Context) error {
|
||||
func (dr *deleteRunner) Run(ctx context.Context) error {
|
||||
plan, err := planparserv2.CreateRetrievePlan(dr.schema.CollectionSchema, dr.req.Expr)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create expr plan, expr = %s", dr.req.GetExpr())
|
||||
return merr.WrapErrParameterInvalidMsg("failed to create delete plan: %v", err)
|
||||
}
|
||||
|
||||
isSimple, pk, numRow := getPrimaryKeysFromPlan(dr.schema.CollectionSchema, plan)
|
||||
|
@ -196,7 +196,7 @@ func createCntPlan(expr string, schema *schemapb.CollectionSchema) (*planpb.Plan
|
||||
|
||||
plan, err := planparserv2.CreateRetrievePlan(schema, expr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, merr.WrapErrParameterInvalidMsg("failed to create query plan: %v", err)
|
||||
}
|
||||
|
||||
plan.Node.(*planpb.PlanNode_Query).Query.IsCount = true
|
||||
@ -219,7 +219,7 @@ func (t *queryTask) createPlan(ctx context.Context) error {
|
||||
if t.plan == nil {
|
||||
t.plan, err = planparserv2.CreateRetrievePlan(schema.CollectionSchema, t.request.Expr)
|
||||
if err != nil {
|
||||
return err
|
||||
return merr.WrapErrParameterInvalidMsg("failed to create query plan: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,8 +194,9 @@ class TestDeleteParams(TestcaseBase):
|
||||
collection_w = self.init_collection_general(prefix, nb=tmp_nb, insert_data=True,
|
||||
is_all_data_type=True, is_index=True)[0]
|
||||
expr = f"{ct.default_float_vec_field_name} in [[0.1]]"
|
||||
error = {ct.err_code: 1,
|
||||
ct.err_msg: f"failed to create expr plan, expr = {expr}"}
|
||||
error = {ct.err_code: 1100,
|
||||
ct.err_msg: f"failed to create delete plan: cannot parse expression: {expr}, "
|
||||
f"error: value '[0.1]' in list cannot be casted to FloatVector: invalid parameter"}
|
||||
|
||||
collection_w.delete(expr, check_task=CheckTasks.err_res, check_items=error)
|
||||
|
||||
@ -1835,8 +1836,9 @@ class TestDeleteString(TestcaseBase):
|
||||
collection_w = \
|
||||
self.init_collection_general(prefix, nb=tmp_nb, insert_data=True, primary_field=ct.default_string_field_name)[0]
|
||||
collection_w.load()
|
||||
error = {ct.err_code: 0,
|
||||
ct.err_msg: f"failed to create expr plan, expr = {default_invalid_string_exp}"}
|
||||
error = {ct.err_code: 1100,
|
||||
ct.err_msg: f"failed to create delete plan: cannot parse expression: {default_invalid_string_exp}, "
|
||||
f"error: comparisons between VarChar and Int64 are not supported: invalid parameter"}
|
||||
collection_w.delete(expr=default_invalid_string_exp,
|
||||
check_task=CheckTasks.err_res, check_items=error)
|
||||
|
||||
|
@ -2466,9 +2466,9 @@ class TestQueryString(TestcaseBase):
|
||||
"""
|
||||
collection_w = self.init_collection_general(prefix, insert_data=True)[0]
|
||||
collection_w.query(expression, check_task=CheckTasks.err_res,
|
||||
check_items={ct.err_code: 65535,
|
||||
ct.err_msg: f"cannot parse expression: {expression}, error: value "
|
||||
f"'0' in list cannot be casted to VarChar"})
|
||||
check_items={ct.err_code: 1100,
|
||||
ct.err_msg: f"failed to create query plan: cannot parse expression: {expression}, "
|
||||
f"error: value '1' in list cannot be casted to VarChar: invalid parameter"})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_query_string_expr_with_binary(self):
|
||||
@ -2541,9 +2541,9 @@ class TestQueryString(TestcaseBase):
|
||||
primary_field=ct.default_string_field_name)[0]
|
||||
expression = 'varchar == int64'
|
||||
collection_w.query(expression, check_task=CheckTasks.err_res,
|
||||
check_items={ct.err_code: 65535, ct.err_msg:
|
||||
f"cannot parse expression: {expression}, error: comparisons between VarChar, "
|
||||
f"element_type: None and Int64 elementType: None are not supported"})
|
||||
check_items={ct.err_code: 1100, ct.err_msg:
|
||||
f"failed to create query plan: cannot parse expression: {expression}, "
|
||||
f"error: comparisons between VarChar and Int64 are not supported: invalid parameter"})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.xfail(reason="issue 24637")
|
||||
|
Loading…
Reference in New Issue
Block a user