HappenLee opened a new pull request, #71284: URL: https://github.com/apache/doris/pull/71284
### Background Doris hashes distribution keys when writing rows to tablets. The FE must hash query literals identically to prune tablets or route a short-circuit point query to the tablet holding the row. ### What problem does this PR solve? Issue Number: None Related PR: #24965 (introduced the IP literal implementations) PR Type: Bugfix Problem Summary: Equality and IN predicates on IPv4/IPv6 hash distribution columns can silently miss existing rows because the FE hashes IP text while the BE hashes binary values. Encode both IP literal types as the same little-endian 4/16-byte values used by existing BE writes. This fixes ordinary scans and short-circuit point queries without redistributing stored data; most of the diff is tests and generated expectations. For example, with three buckets, `198.51.100.169` is written to bucket 2, but the old FE hashes its text and selects bucket 1. The corrected FE selects bucket 2. ### Details - **Change map:** 25 production lines, 215 unit-test lines, 84 SQL-suite lines, and 393 generated expectation lines. - **Frequency:** Deterministic for keys whose text and binary CRC32 hashes select different buckets. Single-bucket tables mask the defect. - **Root cause:** `IPv4Literal` and `IPv6Literal` inherit the UTF-8 implementation of `LiteralExpr.getHashValue()`. `PartitionKey` feeds those bytes to CRC32, whereas BE tablet routing hashes the binary IP value. - **Why existing tests missed it:** `LiteralExprEqualsTest` and `LiteralExprCompareLiteralTest` exercise equality/comparison, not distribution encoding. The existing pruner tests do not cover IP keys. BE `DataTypeIPTest.Crc32Test` compares BE paths with one another. Regression suites such as `test_ip_crud` and `test_ip_basic` distribute by other columns, leaving the IP pruning path untested. - **Fix:** Override the two literal encoders, reuse the existing IPv6 parser, and preserve BE routing. Test independent byte/CRC goldens, equality/IN pruning, compound keys, IPv6 aliases, mapped addresses, and NULLs. - **Other paths and branches:** Both normal and short-circuit routing share the corrected method. Auditing supported scalar literals found no additional instance of this text/binary mismatch; 22 scalar encoding cases cover integers, decimals, dates/timestamps, UUID, strings, booleans and NULL. FLOAT/DOUBLE and complex types are rejected as distribution keys; TIME and VARBINARY cannot be stored in OLAP tables. The same missing IP overrides exist in `branch-3.1`, `branch-4.0`, `branch-4.1`, and `branch-4.2`; backports need adapting the older source/test module paths and IPv6 parser helper. - **Behavior change:** IP predicates now find existing rows in the correct tablet; write routing, storage formats and configuration remain unchanged. ### Testing - `run-fe-ut.sh --run` with `IpLiteralHashTest`, `DistributionLiteralEncodingTest`, `HashDistributionPrunerTest`, and `PartitionKeyTest`: 56 cases passed locally. The 11 IP encoding cases failed on the unmodified baseline and passed after the fix. - `build.sh --fe -j48`: passed, including Java Checkstyle. - `run-regression-test.sh --run -d datatype_p0/ip -s test_ip_hash_distribution`: generated expectations, then passed normal comparison. Independently checked all 124 result sections against inserted values. Covers 1/2/3/8 buckets, both query modes, missing keys, IN, IPv6 aliases, and nullable composite keys. - SQL ran with the candidate FE and an existing BE build (`049410596f4`), using isolated fresh storage. Matching-head BE CI is pending. The new p0 suite has no Docker/nonConcurrent requirement and is not excluded by the P0 configuration. ### Release note Fix missing rows when querying hash-distributed IPv4 or IPv6 columns, including short-circuit point queries. ### Check List (For Author) - Test: Unit tests and local regression (see Testing) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Ready ### AI Disclosure - Tool: Codex (GPT-6) - Generated: Implementation, tests, analysis and this description. - Human review: The author approved the fix direction; no human review of the generated patch has been reported. Codex performed the local self-review. - Prompts: Asked to fix IP hash routing, submit a PR, and check whether other data types have the same problem. -- 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]
