|
79 | 79 | NULL = CaselessKeyword("null")
|
80 | 80 | NAN = CaselessKeyword("nan")
|
81 | 81 | LIKE = CaselessKeyword("like")
|
| 82 | +BETWEEN = CaselessKeyword("between") |
82 | 83 |
|
83 | 84 | unquoted_identifier = Word(alphas + "_", alphanums + "_$")
|
84 | 85 | quoted_identifier = QuotedString('"', escChar="\\", unquoteResults=True)
|
@@ -106,6 +107,7 @@ def _(result: ParseResults) -> Reference:
|
106 | 107 | string = sgl_quoted_string.set_results_name("raw_quoted_string")
|
107 | 108 | decimal = common.real().set_results_name("decimal")
|
108 | 109 | integer = common.signed_integer().set_results_name("integer")
|
| 110 | +number = common.number().set_results_name("number") |
109 | 111 | literal = Group(string | decimal | integer | boolean).set_results_name("literal")
|
110 | 112 | literal_set = Group(
|
111 | 113 | DelimitedList(string) | DelimitedList(decimal) | DelimitedList(integer) | DelimitedList(boolean)
|
@@ -149,8 +151,16 @@ def _(result: ParseResults) -> Literal[L]:
|
149 | 151 | left_ref = column + comparison_op + literal
|
150 | 152 | right_ref = literal + comparison_op + column
|
151 | 153 | comparison = left_ref | right_ref
|
| 154 | +between = column + BETWEEN + number + AND + number |
152 | 155 |
|
153 | 156 |
|
| 157 | +@between.set_parse_action |
| 158 | +def _(result: ParseResults) -> BooleanExpression: |
| 159 | + return And( |
| 160 | + GreaterThanOrEqual(result.column, result[2]), |
| 161 | + LessThanOrEqual(result.column, result[4]) |
| 162 | + ) |
| 163 | + |
154 | 164 | @left_ref.set_parse_action
|
155 | 165 | def _(result: ParseResults) -> BooleanExpression:
|
156 | 166 | if result.op == "<":
|
@@ -258,7 +268,7 @@ def _evaluate_like_statement(result: ParseResults) -> BooleanExpression:
|
258 | 268 | return EqualTo(result.column, StringLiteral(literal_like.value.replace("\\%", "%")))
|
259 | 269 |
|
260 | 270 |
|
261 |
| -predicate = (comparison | in_check | null_check | nan_check | starts_check | boolean).set_results_name("predicate") |
| 271 | +predicate = (between | comparison | in_check | null_check | nan_check | starts_check | boolean).set_results_name("predicate") |
262 | 272 |
|
263 | 273 |
|
264 | 274 | def handle_not(result: ParseResults) -> Not:
|
|
0 commit comments