boluor opened a new pull request, #63326: URL: https://github.com/apache/doris/pull/63326
## Proposed changes Issue Number: close #62672 ### Problem On `IPv4`/`IPv6` columns, when a query has multiple `!=` (or `NOT`) predicates on the same column, only the first condition takes effect. For example: ```sql select * from t where a != '::ffff:1.1.1.1' and a != '::ffff:1.1.1.2'; ``` `EXPLAIN` shows the second predicate is dropped entirely: ``` PREDICATES: ((b[#3] = 'b2') AND (a[#2] != "::ffff:1.1.1.1")) ``` ### Root cause Legacy `org.apache.doris.analysis.IPv4Literal` and `IPv6Literal` implemented `compareLiteral()` as `return 0;` regardless of value. Since `LiteralExpr.equals()` is defined as `compareLiteral(other) == 0`, **any two IPv4 literals — and any two IPv6 literals — were considered equal**. When the planner de-duplicates conjuncts via `Expr.equals()`, the two distinct `!=` predicates collapse into one. This also affected ordering / `IN` / min-max / partition pruning on IP columns; the `!=` de-duplication was just the most visible symptom. ### Fix - `IPv4Literal`: compare numerically via the unsigned 32-bit value (`Long.compare`). - `IPv6Literal`: compare via the parsed 128-bit address using `java-ipv6` (same library already used by the Nereids-side `IPv6Literal`), with the parsed value lazily cached. - Add the `java-ipv6` dependency to the `fe-catalog` module. ### Test Added `regression-test/suites/datatype_p0/ip/test_ip_neq_predicate.groovy` covering multiple `!=` and `NOT BETWEEN` predicates on IPv4/IPv6 columns (including IPv4-mapped IPv6 addresses). -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
