sqltaggingsnowflake-cloud-data-platformsnowsql

Snowflake CLI (Snowsql) - query tagging


When a query is run from the snowsql shell, i get to see the generated query id on the UI. Later on if i have to search for the same in the history, i want to search the query id that i can define or someway to tag the query.

Is it possible to create my own query id or tag when i run the query?


Solution

  • You can't create your own query id, but you can use the QUERY_TAG parameter, see here.

    You can later use it when scanning the INFORMATION_SCHEMA.QUERY_HISTORY table, see here, it has a QUERY_TAG column. You can also use a Query Tag filter in the History tab in the UI.

    You can also use LAST_QUERY_ID to obtain the Snowflake-generated QUERY_ID programmatically. And then you it to filter with that in the QUERY_HISTORY table, and also in the UI.