-
-
Save lgavish/4d70f59b75bb516bd39221bbf82585d0 to your computer and use it in GitHub Desktop.
Extracting query logs from Snowflake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
"QUERY_TEXT", | |
"DATABASE_NAME", | |
"SCHEMA_NAME", | |
"QUERY_TYPE", | |
"USER_NAME", | |
"ROLE_NAME", | |
"EXECUTION_STATUS", | |
"START_TIME", | |
"END_TIME", | |
"TOTAL_ELAPSED_TIME", | |
"BYTES_SCANNED", | |
"ROWS_PRODUCED", | |
"SESSION_ID", | |
"QUERY_ID", | |
"QUERY_TAG", | |
"WAREHOUSE_NAME", | |
"ROWS_INSERTED", | |
"ROWS_UPDATED", | |
"ROWS_DELETED", | |
"ROWS_UNLOADED" | |
FROM snowflake.account_usage.query_history | |
WHERE | |
start_time BETWEEN to_timestamp_ltz('2021-01-01 00:00:00.000000+00:00') AND to_timestamp_ltz('2021-01-01 01:00:00.000000+00:00') | |
AND QUERY_TYPE NOT IN ('DESCRIBE', 'SHOW') | |
AND (DATABASE_NAME IS NULL OR DATABASE_NAME NOT IN ('UTIL_DB', 'SNOWFLAKE')) | |
AND ERROR_CODE is NULL | |
ORDER BY start_time DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment