Redshift, not like PostgreSQL, doesn't display info about last executed query in pg_stat_activity so here is another way to do this.
select s.process, s.user_name, s.db_name, q.querytxt, q.starttime, q.endtime from stv_sessions s left join stl_query q on s.process = q.pid and s.db_name = q.database where s.process = 'chosen session' order by q.starttime desc limit 1;
- process - Process ID of the session
- user_name - user name connected to session
- db_name - database name
- querytxt - most recent query
- starttime - query start time
- endtime - query end time
Query returns just one row.
We can see that last query issued by pid 322 was "select * from event"