Gabriel39 commented on PR #70704:
URL: https://github.com/apache/doris/pull/70704#issuecomment-7151926473

   Reviewed head `a7009e2f1a2c0a4c83ca764e2285bb29b57454c4`. I found two Major 
issues that should be addressed before merging:
   
   1. **Data-prefilter vector searches can retain unbudgeted bucket-sized state 
even with LIMIT 1, without cancellation reaching the active native call.**
   
      [The reader installs the data filter and enters the native bucket read 
here](https://github.com/apache/doris/blob/a7009e2f1a2c0a4c83ca764e2285bb29b57454c4/be/src/format_v2/table/paimon_rust_table_reader.cpp#L888-L892).
 In the pinned paimon-rust v0.5.0, residual filtering constructs and retains 
matching row ranges before ANN. K does not bound this state.
   
      An eligible fully indexed, compacted PK bucket with deletion vectors 
enabled, no merge-on-read, and a non-key INT column alternating between 
matching and nonmatching values reaches this case:
   
      ```sql
      SELECT id FROM catalog.db.tbl
      WHERE flag = 1
      ORDER BY l2_distance_approximate(embedding, [0.0, 0.0])
      LIMIT 1;
      ```
   
      For 100 million alternating physical rows, 50 million disjoint ranges 
require at least 800,000,000 bytes for their two-i64 contents alone, excluding 
capacity and other native allocations. This is a representation-derived lower 
bound, not measured RSS or a reproduced OOM. The integration does not connect 
query-accounted reservations or cancellation to that retained native state.
   
      I acknowledge the PR's disclosed deferral of eager-result memory 
budgeting. This issue is specifically the O(bucket rows) residual-prefilter 
state at K=1 and the missing cancellation bridge, rather than just O(K × 
projected width) result materialization. Please connect budgets and 
cancellation to residual scanning and retained ranges, or decline 
data-prefilter vector admission until those bounds exist. Add a large/selective 
prefilter and cancellation test.
   
   2. **Late CTE inlining loses the virtual score column's ExprId and fails 
plan validation.**
   
      [The new FileScan state introduces the virtual score and cached outputs 
here](https://github.com/apache/doris/blob/a7009e2f1a2c0a4c83ca764e2285bb29b57454c4/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/logical/LogicalFileScan.java#L141-L145).
 Under default CTE settings, this otherwise-admissible V2/Rust vector query 
reaches the problematic copy path:
   
      ```sql
      WITH c AS (
          SELECT id FROM catalog.db.tbl
          ORDER BY l2_distance_approximate(embedding, [0.0, 0.0])
          LIMIT 5
      )
      SELECT * FROM c;
      ```
   
      Early inlining retains the producer because `L2DistanceApproximate` is 
nondeterministic. Vector rewriting replaces it with a virtual score, so late 
CTE normalization then inlines it. `LogicalPlanDeepCopier` allocates a new 
virtual-column ExprId and calls `withVirtualColumns`, but FileScan inherits the 
base no-op implementation and retains its old virtual columns/cached outputs. 
The parent projection references the new score ID while the child exposes the 
old one; Validator rejects this with `A expression contains slot not from 
children`.
   
      Please implement FileScan's virtual-column replacement/remapping 
contract, updating cached outputs and operative slots consistently while 
preserving vector-search metadata. Add coverage through the actual deep copier 
and late single-consumer CTE inlining; shallow with-method tests do not 
exercise this path.
   
   Both findings concern newly supported functionality, not established 
regressions of previously supported VECTOR queries. Validation here was static 
source and pinned-dependency analysis only; I did not run builds, tests, SQL, 
or RSS/OOM measurements.


-- 
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]

Reply via email to