v.25.12Improvement

Add a new

Added a new setting apply_row_policy_after_final that allows the query to apply row policy only after final, which will make the behavior for ReplacingMergeTree with row policies more correct. Fixes #90986. #91065 (Yarik Briukhovetskyi).
Added a new setting apply_row_policy_after_final that controls when row-level security policies are applied in queries involving FINAL, improving correctness for tables like ReplacingMergeTree with row policies.

Why it matters

This feature addresses the issue where row policies were applied before the FINAL clause processing, leading to incorrect query results on tables such as ReplacingMergeTree. By allowing policies to be applied after finalization, it ensures more accurate and expected filtering of rows, enhancing security and correctness.

How to use it

Users can enable this behavior by setting the apply_row_policy_after_final parameter to 1 (true) in their session or configuration. This will make the query apply row policies only after the FINAL modifier is processed.