Snowflake enables you to check last query executed by each session.
To list sessions: List active sessions
Function used in this query return query activity within the last 7 days and maximum 100 of them.
select query_text, warehouse_name, database_name, schema_name, user_name, role_name, execution_status, error_code, error_message, start_time, end_time from table(information_schema.query_history_by_session(session_id)) order by start_time desc -- put session id here limit 1;
- query_text - most recent query text
- warehouse_name - name of warehouse in which query was executed
- database_name - name of database in which query was executed
- schema_name - name of schema in which query was executed
- user_name - name of user who executed query
- role_name - role name of user who executed query
- execution_status - current status of executed query
- error_code - error code, if the query returned an error
- error_message - error message, if the query returned an error
- start_time - start time of query
- end_time - end time of query
Query return just one row with last query information executed by specific session.
Using Web User Interface
In Web User Interface you can watch last query by clicking on Query tab (1) . To obtain last query excuted by specific session, we need to add filter by clicking on Add a filter (2).
Next, select Session ID type of filter (3) and provide session id in text box (4).
The first row shows last query executed by provided session id.