This is an automated email from the ASF dual-hosted git repository.

zclll pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 9383ec642f5 [fix](test) fix JsonBinaryValueTest and 
AcceptNullPredicateTest failures (#61189)
9383ec642f5 is described below

commit 9383ec642f5f81a95baaf4674a73b5f369d100d8
Author: Chenyang Sun <[email protected]>
AuthorDate: Wed Mar 11 00:57:23 2026 +0800

    [fix](test) fix JsonBinaryValueTest and AcceptNullPredicateTest failures 
(#61189)
    
    1. JsonBinaryValueTest.TestValidation: fix assertions to match parser
    behavior
    - Empty string and non-JSON text ('abc') correctly return error since
    c3e418b8 refactored JsonbParser, update EXPECT_TRUE to EXPECT_FALSE
    - Scalar JSON values ('1', 'null', 'false') parse successfully, keep
    EXPECT_TRUE
    
    2. AcceptNullPredicateTest: fix ODR violation with MockIndexIterator
    - MockIndexIterator was defined in both accept_null_predicate_test.cpp
    and function_ip_test.cpp with different has_null() implementations (true
    vs false)
    - Linker picked function_ip_test's vtable, causing has_null() to always
    return false
    - Wrap Mock classes in anonymous namespace to ensure each TU uses its
    own vtable
---
 be/test/core/value/jsonb_value_test.cpp                 | 17 ++++++++++++-----
 be/test/exec/operator/query_cache_operator_test.cpp     |  9 +++++++--
 .../storage/predicate/accept_null_predicate_test.cpp    |  3 +++
 3 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/be/test/core/value/jsonb_value_test.cpp 
b/be/test/core/value/jsonb_value_test.cpp
index 046db7f8b0c..81171795080 100644
--- a/be/test/core/value/jsonb_value_test.cpp
+++ b/be/test/core/value/jsonb_value_test.cpp
@@ -28,14 +28,21 @@ namespace doris {
 TEST(JsonBinaryValueTest, TestValidation) {
     JsonBinaryValue json_val;
 
-    // single value not wrapped as an arrar or object is invalid
-    std::vector<string> invalid_strs = {"", "1", "null", "false", "abc"};
+    // Empty string and non-JSON text should fail to parse
+    std::vector<string> invalid_strs = {"", "abc"};
     for (size_t i = 0; i < invalid_strs.size(); i++) {
         auto status = json_val.from_json_string(invalid_strs[i].c_str(), 
invalid_strs[i].size());
-        EXPECT_TRUE(status.ok());
+        EXPECT_FALSE(status.ok()) << "Should fail for: [" << invalid_strs[i] 
<< "]";
     }
 
-    // valid enums
+    // Scalar JSON values (number, null, boolean) are valid JSON and should 
parse OK
+    std::vector<string> scalar_strs = {"1", "null", "false"};
+    for (size_t i = 0; i < scalar_strs.size(); i++) {
+        auto status = json_val.from_json_string(scalar_strs[i].c_str(), 
scalar_strs[i].size());
+        EXPECT_TRUE(status.ok()) << "Should succeed for: [" << scalar_strs[i] 
<< "]";
+    }
+
+    // valid arrays and objects
     std::vector<string> valid_strs;
     valid_strs.push_back("[false]");
     valid_strs.push_back("[-123]");
@@ -45,7 +52,7 @@ TEST(JsonBinaryValueTest, TestValidation) {
     valid_strs.push_back("[123, {\"key1\": null, \"key2\": [\"val1\", 
\"val2\"]}]");
     for (size_t i = 0; i < valid_strs.size(); i++) {
         auto status = json_val.from_json_string(valid_strs[i].c_str(), 
valid_strs[i].size());
-        EXPECT_TRUE(status.ok());
+        EXPECT_TRUE(status.ok()) << "Should succeed for: [" << valid_strs[i] 
<< "]";
     }
 }
 } // namespace doris
\ No newline at end of file
diff --git a/be/test/exec/operator/query_cache_operator_test.cpp 
b/be/test/exec/operator/query_cache_operator_test.cpp
index 7bc2bc5830a..0f3ae8acce8 100644
--- a/be/test/exec/operator/query_cache_operator_test.cpp
+++ b/be/test/exec/operator/query_cache_operator_test.cpp
@@ -62,6 +62,13 @@ struct QueryCacheOperatorTest : public ::testing::Test {
         scan_range.scan_range.__set_palo_scan_range(palp_scan_range);
         scan_ranges.push_back(scan_range);
     }
+    void TearDown() override {
+        // Must clear state before query_cache_uptr is destroyed, because
+        // local states inside `state` hold QueryCacheHandle which references
+        // the QueryCache. C++ destroys members in reverse declaration order,
+        // so state (declared before query_cache_uptr) would outlive the cache.
+        state.reset();
+    }
     void create_local_state() {
         shared_state = sink->create_shared_state();
         {
@@ -261,8 +268,6 @@ TEST_F(QueryCacheOperatorTest, test_hit_cache) {
         EXPECT_TRUE(eos);
         EXPECT_TRUE(block.empty());
     }
-
-    query_cache_uptr.release();
 }
 
 } // namespace doris
\ No newline at end of file
diff --git a/be/test/storage/predicate/accept_null_predicate_test.cpp 
b/be/test/storage/predicate/accept_null_predicate_test.cpp
index d5a807177e7..e66ca503d5d 100644
--- a/be/test/storage/predicate/accept_null_predicate_test.cpp
+++ b/be/test/storage/predicate/accept_null_predicate_test.cpp
@@ -29,6 +29,7 @@
 #include "storage/predicate/comparison_predicate.h"
 
 namespace doris {
+namespace {
 
 class MockLRUCachePolicy : public LRUCachePolicy {
 public:
@@ -103,6 +104,8 @@ private:
     std::shared_ptr<roaring::Roaring> _result_bitmap;
 };
 
+} // anonymous namespace
+
 class AcceptNullPredicateTest : public testing::Test {
 public:
     AcceptNullPredicateTest() = default;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to