github-actions[bot] commented on code in PR #70844:
URL: https://github.com/apache/doris/pull/70844#discussion_r4657704792


##########
be/src/exprs/function/function_bitmap.cpp:
##########
@@ -773,6 +774,17 @@ class FunctionBitmapAndNotCount : public IFunction {
     }
 };
 
+namespace {
+uint64_t checked_bitmap_element(Int64 value, const char* function_name) {
+    // -1 is not UINT64_MAX. Reject it before contains/remove can access a 
different element.
+    if (value < 0) {

Review Comment:
   [P2] Preserve NULL payload handling before validating bitmap elements
   
   For a BIGINT column `n` containing `-1` and `1` in one block, `SELECT 
bitmap_contains(to_bitmap(1), nullif(n, -1)) FROM t` now throws instead of 
returning NULL and true. `NULLIF` delegates to `IF`, which wraps the original 
`[-1,1]` values with null map `[1,0]`, retaining the hidden `-1`. 
`FunctionBinaryToType` inherits `need_replace_null_data_to_default=false`, so 
default nullable unwrapping passes that payload into this check before 
restoring NULL. `bitmap_remove` has the same regression. Clear or skip NULL 
element payloads before validation, and cover mixed NULL/non-NULL vectors for 
both functions.



##########
be/src/exprs/function/function_bitmap.cpp:
##########
@@ -789,19 +801,20 @@ struct BitmapContains {
     static void vector_vector(const LTData& lvec, const RTData& rvec, 
ResTData& res) {
         size_t size = lvec.size();
         for (size_t i = 0; i < size; ++i) {
-            res[i] = lvec[i].contains(rvec[i]);
+            res[i] = lvec[i].contains(checked_bitmap_element(rvec[i], 
"bitmap_contains"));

Review Comment:
   [P2] Preserve signed probes in bitmap IN-subquery rewrites
   
   `ExpressionAnalyzer.visitInSubquery` accepts signed BIGINT probes, and 
`InApplyToJoin` lowers `k NOT IN (SELECT b FROM bitmap_table)` to this reduced 
tree:
   
   ```text
   LeftSemiJoin[NOT bitmap_contains(u, k)]
     Scan signed_keys[k]
     Aggregate[bitmap_union(b) AS u]
       Scan bitmap_table[b]
   ```
   
   With `k=-1` and bitmap `{1}`, this query previously returned the row but now 
aborts in the new check. There is no nonnegative-domain guard in the lowering; 
ordinary IN probes also error instead of failing membership. Preserve signed 
membership semantics in the optimizer lowering while applying the intended 
direct-call validation contract, and add negative-key tests for both IN and NOT 
IN. This concerns actual non-NULL probe values, separately from the 
NULL-payload issue.



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