@@ -659,20 +659,18 @@ struct HashJoinSharedState : public JoinSharedState {
659659 // Cached build ASOF column (computed once by executing expression on build_block)
660660 vectorized::ColumnPtr asof_build_col;
661661
662- // ASOF RIGHT JOIN: column-based cache for efficient accumulation across probe batches
663- // Per build row (1-indexed, 0 unused): whether a matching probe was found
662+ // ASOF RIGHT JOIN: per-task local caches submitted during finish_probing, then merged
663+ // Each probe task accumulates matches lock-free in its own AsofRightLocalCache.
664+ // The last task to enter finish_probing merges all caches and populates merged_* for output.
665+ std::vector<AsofRightLocalCache> asof_right_local_caches;
666+ std::mutex asof_right_submit_mutex; // only for submitting local caches (one lock per task)
667+ // Merged result (populated once by last task during finish_probing merge)
664668 std::vector<uint8_t > asof_right_has_match;
665- // Per build row: index into probe cache for the best matching probe row (-1 = none)
666669 std::vector<int32_t > asof_right_cache_idx;
667- // Append-only column of best probe ASOF values (for efficient compare_at, no Field)
668- vectorized::MutableColumnPtr asof_right_best_probe_values;
669- // Append-only cache of full probe row data (for output in finish_probing)
670670 std::unique_ptr<vectorized::MutableBlock> asof_right_probe_cache;
671671 size_t asof_right_output_idx = 0 ;
672- // Barrier: counts down from num_probe_tasks. Only the last task (counter→0) outputs.
672+ // Barrier: counts down from num_probe_tasks. Only the last task (counter→0) merges+ outputs.
673673 std::atomic<int32_t > asof_right_remaining_probers {0 };
674- // Mutex protecting concurrent writes to probe_cache/best_probe_values/has_match/cache_idx
675- std::mutex asof_right_cache_mutex;
676674};
677675
678676struct PartitionedHashJoinSharedState
0 commit comments