v.23.7Bug Fix

Fix optimize_skip_unused_shards with JOINs

Fix optimize_skip_unused_shards with JOINs #51037 (Azat Khuzhin).