2021-06-10 07:43:49 +08:00
|
|
|
|
```haskell
|
2021-10-23 16:50:02 +08:00
|
|
|
|
Expr :=
|
2021-06-10 07:43:49 +08:00
|
|
|
|
LogicalExpr | NIL
|
|
|
|
|
|
2021-10-23 16:50:02 +08:00
|
|
|
|
LogicalExpr :=
|
|
|
|
|
LogicalExpr BinaryLogicalOp LogicalExpr
|
2021-06-10 07:43:49 +08:00
|
|
|
|
| UnaryLogicalOp LogicalExpr
|
|
|
|
|
| "(" LogicalExpr ")"
|
|
|
|
|
| SingleExpr
|
|
|
|
|
|
2021-10-23 16:50:02 +08:00
|
|
|
|
BinaryLogicalOp :=
|
|
|
|
|
"&&" | "and"
|
2021-06-10 07:43:49 +08:00
|
|
|
|
| "||" | "or"
|
|
|
|
|
|
|
|
|
|
UnaryLogicalOp :=
|
|
|
|
|
"not"
|
|
|
|
|
|
2021-10-23 16:50:02 +08:00
|
|
|
|
SingleExpr :=
|
2021-06-10 07:43:49 +08:00
|
|
|
|
TermExpr
|
|
|
|
|
| CompareExpr
|
|
|
|
|
|
2021-10-23 16:50:02 +08:00
|
|
|
|
TermExpr :=
|
2021-06-10 07:43:49 +08:00
|
|
|
|
IDENTIFIER "in" ConstantArray
|
|
|
|
|
|
2021-10-23 16:50:02 +08:00
|
|
|
|
ConstantArray :=
|
2021-07-15 11:25:54 +08:00
|
|
|
|
"[" ConstantExpr { "," ConstantExpr } "]"
|
2021-10-23 16:50:02 +08:00
|
|
|
|
|
|
|
|
|
ConstantExpr :=
|
2021-07-15 11:25:54 +08:00
|
|
|
|
Constant
|
|
|
|
|
| ConstantExpr BinaryArithOp ConstantExpr
|
|
|
|
|
| UnaryArithOp ConstantExpr
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2021-10-23 16:50:02 +08:00
|
|
|
|
Constant :=
|
2023-10-24 09:30:10 +08:00
|
|
|
|
INTEGER
|
2021-07-15 11:25:54 +08:00
|
|
|
|
| FLOAT_NUMBER
|
2021-10-23 16:50:02 +08:00
|
|
|
|
|
|
|
|
|
UnaryArithOp :=
|
2021-07-15 11:25:54 +08:00
|
|
|
|
"+"
|
|
|
|
|
| "-"
|
|
|
|
|
|
2021-10-23 16:50:02 +08:00
|
|
|
|
BinaryArithOp :=
|
2021-07-15 11:25:54 +08:00
|
|
|
|
"+"
|
|
|
|
|
| "-"
|
|
|
|
|
| "*"
|
|
|
|
|
| "/"
|
|
|
|
|
| "%"
|
|
|
|
|
| "**"
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2021-10-23 16:50:02 +08:00
|
|
|
|
CompareExpr :=
|
2021-07-15 11:25:54 +08:00
|
|
|
|
IDENTIFIER CmpOp IDENTIFIER
|
|
|
|
|
| IDENTIFIER CmpOp ConstantExpr
|
|
|
|
|
| ConstantExpr CmpOp IDENTIFIER
|
|
|
|
|
| ConstantExpr CmpOpRestricted IDENTIFIER CmpOpRestricted ConstantExpr
|
2021-10-23 16:50:02 +08:00
|
|
|
|
|
|
|
|
|
CmpOpRestricted :=
|
2021-07-15 11:25:54 +08:00
|
|
|
|
"<"
|
|
|
|
|
| "<="
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2021-10-23 16:50:02 +08:00
|
|
|
|
CmpOp :=
|
2021-06-10 07:43:49 +08:00
|
|
|
|
">"
|
|
|
|
|
| ">="
|
|
|
|
|
| "<"
|
|
|
|
|
| "<="
|
|
|
|
|
| "=="
|
|
|
|
|
| "!="
|
|
|
|
|
|
2023-10-24 09:30:10 +08:00
|
|
|
|
INTEGER := 整数
|
2021-06-10 07:43:49 +08:00
|
|
|
|
FLOAT_NUM := 浮点数
|
|
|
|
|
IDENTIFIER := 列名
|
|
|
|
|
```
|
|
|
|
|
|
2021-07-15 11:25:54 +08:00
|
|
|
|
Tips:
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2021-09-23 16:36:01 +08:00
|
|
|
|
1. NIL represents an empty string, which means there is no Predicate for Expr.
|
2022-01-04 19:11:46 +08:00
|
|
|
|
2. Gramma is described by EBNF syntax, expressions that may be omitted or repeated are represented through curly braces `{...}`.
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2021-11-03 17:28:17 +08:00
|
|
|
|
After syntax analysis, the following rules will be applied:
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2022-01-05 09:49:24 +08:00
|
|
|
|
1. Non-vector column must exist in Schema.
|
2021-07-15 11:25:54 +08:00
|
|
|
|
2. CompareExpr/TermExpr requires operand type matching.
|
2021-12-08 10:43:04 +08:00
|
|
|
|
3. CompareExpr between non-vector columns of different types is available.
|
2021-07-15 11:25:54 +08:00
|
|
|
|
4. The modulo operation requires all operands to be integers.
|
2021-11-03 17:28:17 +08:00
|
|
|
|
5. Integer columns can only match integer operands. While float columns can match both integer and float operands.
|
2021-12-17 17:29:25 +08:00
|
|
|
|
6. In BinaryOp, the `and`/`&&` operator has a higher priority than the `or`/`||` operator.
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
2021-12-13 11:05:28 +08:00
|
|
|
|
Example:
|
2021-06-10 07:43:49 +08:00
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
A > 3 && A < 4 && (C > 5 || D < 6)
|
2021-07-15 11:25:54 +08:00
|
|
|
|
1 < A <= 2.0 + 3 - 4 * 5 / 6 % 7 ** 8
|
|
|
|
|
A == B
|
2021-06-10 07:43:49 +08:00
|
|
|
|
FloatCol in [1.0, 2, 3.0]
|
|
|
|
|
Int64Col in [1, 2, 3] or C != 6
|
|
|
|
|
```
|