fix not in bug (#5741)

Signed-off-by: fluorinedog <fluorinedog@gmail.com>
pull/5768/head
FluorineDog 2021-06-11 17:08:25 +08:00 committed by GitHub
parent 902307327b
commit 4165b761c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -192,6 +192,9 @@ func (context *ParserContext) handleArrayExpr(node *ant_ast.Node, dataType schem
}
func (context *ParserContext) handleInExpr(node *ant_ast.BinaryNode) (*planpb.Expr, error) {
if node.Operator != "in" && node.Operator != "not in" {
return nil, fmt.Errorf("invalid Operator(%s)", node.Operator)
}
idNode, ok := node.Left.(*ant_ast.IdentifierNode)
if !ok {
return nil, fmt.Errorf("left operand of the InExpr must be identifier")
@ -213,6 +216,10 @@ func (context *ParserContext) handleInExpr(node *ant_ast.BinaryNode) (*planpb.Ex
},
},
}
if node.Operator == "not in" {
return context.createNotExpr(expr)
}
return expr, nil
}

View File

@ -126,6 +126,7 @@ func TestExprPlan_Str(t *testing.T) {
exprStrs := []string{
"age >= 420000 && age < 420010", // range
"age == 420000 || age == 420001 || age == 420002 || age == 420003 || age == 420004", // term
"age not in [1, 2, 3]",
}
for offset, exprStr := range exprStrs {