# Snowflake Table

This class stores result log data in a common Snowflake table.

Consider using [Snowflake Hybird Table](https://docs.snowkill.net/storage/built-in-storages/snowflake-hybrid-table) storage instead if it is available for your account.

This storage method requires an active warehouse and it consumes some credits. But warehouse is only started when you have new results to store. If all results are old, this storage class retrieves data from query cache.

The final cost is proportional to the frequency of newly reported matched queries. If notifications are relatively rare, the cost should be negligible.

### Setup

Snowflake table storage requires you to create a table and to assign a warehouse for SnowKill [administration user](https://docs.snowkill.net/implementation-details/administration-user).

```sql
CREATE DATABASE UTILS;
CREATE SCHEMA UTILS.MONITOR;

CREATE TABLE UTILS.MONITOR.SNOWKILL_LOG
(
    query_id VARCHAR(16777216),
    check_result_level NUMBER(38,0),
    check_result_name VARCHAR(16777216),
    check_result_description VARCHAR(16777216),
    check_result_time TIMESTAMP_NTZ(6)
);

CREATE WAREHOUSE ADMIN_MONITOR_WH
WAREHOUSE_SIZE = XSMALL
AUTO_SUSPEND = 60
INITIALLY_SUSPENDED = TRUE;

ALTER USER ADMIN_MONITOR SET
DEFAULT_WAREHOUSE = ADMIN_MONITOR_WH;
```

Please note the full name of created table. It should be passed to `SnowflakeTableStorage` constructor.

### Example

```python
snowkill_storage = SnowflakeTableStorage(connection, getenv("SNOWFLAKE_TARGET_TABLE"))
check_results = snowkill_storage.store_and_remove_duplicate(check_results)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.snowkill.net/storage/built-in-storages/snowflake-table.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
