fix: fix not equal not include None (#44959)

#44816

Signed-off-by: luzhang <luzhang@zilliz.com>
Co-authored-by: luzhang <luzhang@zilliz.com>
This commit is contained in:
zhagnlu 2025-10-21 17:08:03 +08:00 committed by GitHub
parent cfae60093c
commit 730308b1eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 5 deletions

View File

@ -1808,7 +1808,7 @@ TEST_P(ExprTest, TestUnaryRangeJsonNullable) {
case OpType::NotEqual: {
f = [&](int64_t value, bool valid) {
if (!valid) {
return false;
return true;
}
return value != testcase.val;
};
@ -1938,7 +1938,7 @@ TEST_P(ExprTest, TestUnaryRangeJsonNullable) {
for (const auto& testcase : array_cases) {
auto check = [&](OpType op, bool valid) {
if (!valid) {
return false;
return op == OpType::NotEqual ? true : false;
}
if (testcase.nested_path[0] == "array" && op == OpType::Equal) {
return true;
@ -12001,7 +12001,7 @@ TEST_P(ExprTest, TestUnaryRangeWithJSONNullable) {
[](std::variant<int64_t, bool, double, std::string_view> v,
bool valid) {
if (!valid) {
return false;
return true;
}
return !std::get<bool>(v);
},

View File

@ -860,7 +860,8 @@ PhyUnaryRangeFilterExpr::ExecRangeVisitorImplJson(EvalCtx& context) {
offset = (offsets) ? offsets[i] : i;
}
if (valid_data != nullptr && !valid_data[offset]) {
res[i] = valid_res[i] = false;
valid_res[i] = false;
res[i] = true;
continue;
}
if (has_bitmap_input &&
@ -992,7 +993,11 @@ PhyUnaryRangeFilterExpr::ExecRangeVisitorImplJsonByStats() {
: std::stoi(pointerpair.second);
ExprValueType val = GetValueFromProto<ExprValueType>(expr_->val_);
auto op_type = expr_->op_type_;
// for NotEqual: compute Equal and flip the result
// this avoids handling NULL values differently in multiple places
auto op_type = (expr_->op_type_ == proto::plan::OpType::NotEqual)
? proto::plan::OpType::Equal
: expr_->op_type_;
auto segment = static_cast<const segcore::SegmentSealed*>(segment_);
auto field_id = expr_->column_.field_id_;
@ -1265,6 +1270,10 @@ PhyUnaryRangeFilterExpr::ExecRangeVisitorImplJsonByStats() {
}
}
// for NotEqual: flip the result
if (expr_->op_type_ == proto::plan::OpType::NotEqual) {
cached_index_chunk_res_->flip();
}
cached_index_chunk_id_ = 0;
}