You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "boluor (via GitHub)" <gi...@apache.org> on 2026/05/17 13:44:27 UTC
[PR] [fix](fe) Fix IPv4/IPv6 literal compareLiteral always returning 0 [doris]
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](fe) Fix IPv4/IPv6 literal compareLiteral always returning 0 [doris]
Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on PR #63326:
URL: https://github.com/apache/doris/pull/63326#issuecomment-4591484151
dup with https://github.com/apache/doris/pull/63481
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](fe) Fix IPv4/IPv6 literal compareLiteral always returning 0 [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #63326:
URL: https://github.com/apache/doris/pull/63326#issuecomment-4470861317
Thank you for your contribution to Apache Doris.
Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/How+to+process+your+PR).
Please clearly describe your PR:
1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
3. What features were added. Why was this function added?
4. Which code was refactored and why was this part of the code refactored?
5. Which functions were optimized and what is the difference before and after the optimization?
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix](fe) Fix IPv4/IPv6 literal compareLiteral always returning 0 [doris]
Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow closed pull request #63326: [fix](fe) Fix IPv4/IPv6 literal compareLiteral always returning 0
URL: https://github.com/apache/doris/pull/63326
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org