v.24.5Bug Fix

Fix query analysis for Distributed tables with final setting in non-MergeTree tables

Fix query analysis for queries with the setting final = 1 for Distributed tables over tables from other than the MergeTree family. #64037 (Nikolai Kochetov).