Quick Sight can’t run SET. Custom SQL in Quick Sight must be a single SELECT statement (no SET, no multi-statements, no stored procs).
Create an RLS rules dataset that maps users/groups to allowed keys, then apply it to your dataset. This is fully supported and maintained by AWS (note the new Rules dataset flag added in 2025).
Please refer to the below documentations this might be helpful for you.