@@ -154,20 +154,23 @@ TEST_F(VRuntimeFilterWrapperSamplingTest, sampling_frequency_survives_context_re
154154 wrapper->open (_runtime_states[0 ].get (), context1.get (), FunctionContext::FRAGMENT_LOCAL )
155155 .ok ());
156156
157- // Simulate context recreation (what _append_rf_into_conjuncts does):
158- // Create a brand new VExprContext with the same VRuntimeFilterWrapper.
159- // The new context starts with default sampling_frequency = -1 .
157+ // Create a brand new non-clone VExprContext with the same VRuntimeFilterWrapper,
158+ // matching the production path in _append_rf_into_conjuncts which calls
159+ // VExprContext::create_shared(expr) then conjunct->prepare() and conjunct->open() .
160160 auto context2 = std::make_shared<VExprContext>(wrapper);
161161 EXPECT_FALSE (context2->get_runtime_filter_selectivity ().maybe_always_true_can_ignore ());
162162
163- // After open() on the new context, sampling_frequency should be propagated
164- ASSERT_TRUE (
165- wrapper->open (_runtime_states[0 ].get (), context2.get (), FunctionContext::THREAD_LOCAL )
166- .ok ());
167- // Prepare/open the recreated context through VExprContext so the test matches
168- // the production lifecycle and context-managed initialization.
163+ // Drive the recreated context through prepare/open via VExprContext (not the
164+ // wrapper directly), matching the production _append_rf_into_conjuncts lifecycle.
169165 ASSERT_TRUE (context2->prepare (_runtime_states[0 ].get (), row_desc).ok ());
170166 ASSERT_TRUE (context2->open (_runtime_states[0 ].get ()).ok ());
167+
168+ // After open(), sampling_frequency should be propagated from VRuntimeFilterWrapper
169+ // to context2. Verify by accumulating low-selectivity data and checking that
170+ // always_true can be detected — this is the actual behavior the fix protects.
171+ auto & selectivity = context2->get_runtime_filter_selectivity ();
172+ selectivity.update_judge_selectivity (1 , 2000 , 50000 , 0.1 );
173+ EXPECT_TRUE (selectivity.maybe_always_true_can_ignore ());
171174}
172175
173176} // namespace doris
0 commit comments