Update query_boolean_expr.md (#6494)

Signed-off-by: xaxys <tpnnghd@163.com>
This commit is contained in:
xaxys 2021-07-15 11:25:54 +08:00 committed by GitHub
parent 1fd1ad4d80
commit 5568dffa04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,15 +23,38 @@ TermExpr :=
IDENTIFIER "in" ConstantArray IDENTIFIER "in" ConstantArray
ConstantArray := ConstantArray :=
"[" Constant+, "]" "[" ConstantExpr { "," ConstantExpr } "]"
ConstantExpr :=
Constant
| ConstantExpr BinaryArithOp ConstantExpr
| UnaryArithOp ConstantExpr
Constant := Constant :=
INTERGER INTERGER
| FLOAT_NUMBER | FLOAT_NUMBER
UnaryArithOp :=
"+"
| "-"
BinaryArithOp :=
"+"
| "-"
| "*"
| "/"
| "%"
| "**"
CompareExpr := CompareExpr :=
IDENTIFIER CmpOp Constant IDENTIFIER CmpOp IDENTIFIER
| Constant CmpOp IDENTIFIER | IDENTIFIER CmpOp ConstantExpr
| ConstantExpr CmpOp IDENTIFIER
| ConstantExpr CmpOpRestricted IDENTIFIER CmpOpRestricted ConstantExpr
CmpOpRestricted :=
"<"
| "<="
CmpOp := CmpOp :=
">" ">"
@ -46,23 +69,26 @@ FLOAT_NUM := 浮点数
IDENTIFIER := 列名 IDENTIFIER := 列名
``` ```
注意, Tips:
1. NIL 态为空字符串, 代表无 Predicate 的情形 1. NIL represent a empty string, which means there is no Predicate for Expr.
2. ”+,” 代表逗号分隔的,且至少有一个元素的重复元素 2. Gramma is described by EBNF syntaxexpressions that may be omitted or repeated are represented through curly braces `{...}`.
语法分析后,执行以下静态检查规则 After syntax analysis, following rules will be applied:
1. 列名必须存在于 Schema 中,且不是向量类型 1. non-vector column must exist in Schema.
2. CompareExpr/TermExpr 要求左右类型匹配 2. CompareExpr/TermExpr requires operand type matching.
3. 整型列必须对应整型数据 3. CompareExpr between non-vector columns of different types is available
1. 浮点列可以对应浮点数据或整型数据 4. The modulo operation requires all operands to be integers.
2. BinaryOp 中,“与操作符” 的优先级高于 “或操作符“ 5. Integer columns can only match integer operands. But float columns can match both integer and float operands.
6. In BinaryOp, the `and`/`&&` operator has higher priority than the `or`/`||` operator
简单举例说明 example
```python ```python
A > 3 && A < 4 && (C > 5 || D < 6) A > 3 && A < 4 && (C > 5 || D < 6)
1 < A <= 2.0 + 3 - 4 * 5 / 6 % 7 ** 8
A == B
FloatCol in [1.0, 2, 3.0] FloatCol in [1.0, 2, 3.0]
Int64Col in [1, 2, 3] or C != 6 Int64Col in [1, 2, 3] or C != 6
``` ```