Is there a way to pass the logged in user name to an SQL custom query or a filter?

Hi, I have a single dataset table containing data for multiple users .
I would like to make sure different users only have access to their data.
Currently I was able to achieve this either buy creating a different data source for each user with custom SQL query to RDS specifying in the query the username or applying row level security by manually imputing all the user names in a RLS file mapped to a userID.
Is there a way of just pulling somehow the user name of the current user into a variable so I can automate the SQL query?
I also welcome any suggestion on best practice on how to automate this process as we add more users over time.
We are thinking to use Cognito as our user authentication in our web app to give users access to Quicksight but also other services at once.
If they use Quicksight they should be by default only access their data.
Any help very welcome , thank you very much!

You should set up Row Level Security for this dataset and then QuickSight will make sure that only the rows corresponding to each user are used in data presented to each user.

See Using row-level security (RLS) with user-based rules to restrict access to a dataset - Amazon QuickSight

1 Like

as darcoli says, Row Level Security (RLS) works great. We refresh the security dataset every hour.

1 Like