RoanHeNaN commented on PR #70552: URL: https://github.com/apache/doris/pull/70552#issuecomment-7193938636
Follow-up on the latest push (`ea9c88689a`, `08ece8c0d1`, `a7289fc99b`). Removing the sparse-segment fallback fixes the main issue from my first comment: sparse segments now use ANN TopN, including MoW segments whose `[]` rows are already masked by the delete bitmap (sequence losers, rows overwritten by a delete). The new `SparseTopNRanksOnlyIndexedCandidates` test is good coverage. `simd::contain_one` is fine. ### The same SQL now returns different rows depending on the execution path The ANN path omits `[]` rows. Every brute-force path still returns them with NULL distances. Brute force is used when: - the segment has no index, or is below `ann_index_build_min_segment_rows`; - the candidate ratio is below `ann_index_candidate_rows_percent_threshold` (default 0.3); - there is a filter or common expr, including the implicit MoW `__DORIS_DELETE_SIGN__ = 0` on segments that contain tombstones; - the sort direction is unsupported (DESC for L2, ASC for IP), or the metric does not match. The PR's own tests show this: - `ann_empty_array_mow.groovy` `qt_mow_topn` runs `ORDER BY d ASC NULLS LAST LIMIT 10` with only one visible non-empty row. The suite sets `ann_index_build_min_segment_rows` and both candidate thresholds to 0, which forces ANN, so `08ece8c0d1` drops `100 \N` from the output. With default settings this small table falls back and row 100 comes back. - `ann_empty_array_queries.groovy` keeps separate expected outputs for the `scalar_fallback` phase and the ANN phases, for the same queries. It also mixes within a single query, because the choice is made per segment: - A freshly loaded small segment below the build threshold falls back and sends its `[]` rows with NULL distances to the global TopN. - Large indexed segments omit theirs. - With the default `ASC NULLS FIRST`, those rows from the small segment come first. - Once compaction merges that segment into an indexed one, they disappear. The data hasn't changed, but the result has. In MoW, visible `[]` rows come from partial updates on a deleted key, flexible partial updates with an in-load delete, and `DEFAULT '[]'` fills for new keys. They show up mostly in recent, small segments, so this is the common case rather than an edge case. pgvector also omits NULL rows on its index path, but it picks one plan per query. It never mixes the two semantics across parts of the same table in one query. ### Suggestion Make "missing vectors are not recalled" independent of the plan: - **Preferred:** FE adds an implicit `dist IS NOT NULL` filter for TopN on `l2_distance_approximate` / `inner_product_approximate`. BE drops that filter on the ANN path, where it is implied, and evaluates it on fallback. Details in section 3.1 of my previous comment. - **Or:** BE filters NULL-distance rows on every brute-force TopN path for these two functions. - **At minimum:** the release note should say explicitly that results depend on the execution path and on compaction state. "Scalar fallback retains its existing NULL behavior" doesn't make that clear. Related: a NULL or `[]` query vector still falls back and returns `k` NULL-distance rows. That is also inconsistent with "not recalled" on the ANN path. Returning an empty result would match it. ### Still open from earlier comments - `enable_ann_index_empty_array` is still a BE config, default false. - Nullable ANN columns are still rejected (`IndexDefinition.java` "not nullable" checks). - The Group Commit validation location and the partial-acknowledgement atomicity (P1) are unchanged. - The range-boundary fix and the NULL-element rejection are not split out. ### Minor - The commit message of `08ece8c0d1` reports that the combined BE UT run failed LeakSanitizer (a 224-byte OpenMP allocation, exit 134). Please confirm whether the new tests introduced the leak or it existed before. - The new UT writes many private members of `SegmentIterator` and `AnnTopNRuntime` directly. A small test helper would make it less fragile. -- 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]
