slfan1989 opened a new issue, #4220:
URL: https://github.com/apache/amoro/issues/4220
### Motivation
`ExpressionUtil.convertSqlFilterToIcebergExpression()` converts SQL filter
strings into Iceberg expressions. It currently supports common comparison
operators when the column is on the left side, for example:
```sql
column_a > 1
column_a <= 10
column_a IN (1, 2)
```
However, two common SQL filter forms are not supported yet:
```
column_a BETWEEN 1 AND 10
1 < column_a
```
These filters are valid SQL expressions and are useful when users or
upper-layer services pass SQL-style predicates to Amoro for Iceberg table
filtering.
### Current behavior
The following filter fails with an unsupported expression error:
```
column_a BETWEEN 1 AND 10
```
The following filter fails because ExpressionUtil expects the left
expression to be a column:
```
1 < column_a
```
### Expected behavior
`ExpressionUtil` should convert these SQL filters into equivalent Iceberg
expressions:
```
column_a BETWEEN 1 AND 10
```
should become:
```
Expressions.and(
Expressions.greaterThanOrEqual("column_a", 1),
Expressions.lessThanOrEqual("column_a", 10))
```
```
column_a NOT BETWEEN 1 AND 10
```
should become:
```
Expressions.not(
Expressions.and(
Expressions.greaterThanOrEqual("column_a", 1),
Expressions.lessThanOrEqual("column_a", 10)))
```
Reversed comparisons should also be supported:
```
1 > column_a -> column_a < 1
1 >= column_a -> column_a <= 1
1 < column_a -> column_a > 1
1 <= column_a -> column_a >= 1
1 = column_a -> column_a = 1
1 != column_a -> column_a != 1
```
### Proposed change
Update `ExpressionUtil` to:
- Handle JSQLParser `Between` expressions.
- Convert BETWEEN into `>=` and `<=` Iceberg expressions.
- Convert `NOT BETWEEN` into `not(and(...))`.
- Support comparison expressions where the column appears on the right side.
- Add unit tests in `TestExpressionUtil`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]