KosmoKrator

database

Snowflake Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Snowflake KosmoKrator integration.

9 functions 8 read 1 write Manual OAuth token auth

Lua Namespace

Agents call this integration through app.integrations.snowflake.*. Use lua_read_doc("integrations.snowflake") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Snowflake — Lua API Reference

execute_query

Execute a SQL statement on Snowflake. Returns column metadata and result rows.

Parameters

NameTypeRequiredDescription
sqlstringyesThe SQL statement to execute
warehousestringnoWarehouse to use for the query
databasestringnoDatabase context for the query
schemastringnoSchema context for the query

Examples

Simple SELECT query

local result = app.integrations.snowflake.execute_query({
  sql = "SELECT CURRENT_TIMESTAMP(), CURRENT_DATABASE()"
})

for _, row in ipairs(result.rows) do
  print("Timestamp: " .. row[1])
end

Query with context

local result = app.integrations.snowflake.execute_query({
  sql = "SELECT * FROM orders LIMIT 10",
  warehouse = "COMPUTE_WH",
  database = "SALES_DB",
  schema = "PUBLIC"
})

for _, row in ipairs(result.rows) do
  print(row.id .. ": " .. row.status)
end

Aggregation query

local result = app.integrations.snowflake.execute_query({
  sql = "SELECT COUNT(*) as total, SUM(amount) as revenue FROM sales WHERE year = 2026",
  warehouse = "ANALYTICS_WH",
  database = "ANALYTICS"
})

for _, row in ipairs(result.rows) do
  print("Total: " .. row.total .. ", Revenue: " .. row.revenue)
end

list_databases

List all databases in the Snowflake account.

Parameters

None.

Example

local result = app.integrations.snowflake.list_databases({})

for _, db in ipairs(result.data or {}) do
  print(db.name)
end

get_database

Get details for a specific Snowflake database.

Parameters

NameTypeRequiredDescription
databasestringyesThe database name or identifier

Example

local result = app.integrations.snowflake.get_database({
  database = "ANALYTICS"
})

print("Database: " .. result.name)
print("Owner: " .. (result.owner or "unknown"))

list_schemas

List all schemas within a Snowflake database.

Parameters

NameTypeRequiredDescription
databasestringyesThe database name

Example

local result = app.integrations.snowflake.list_schemas({
  database = "ANALYTICS"
})

for _, schema in ipairs(result.data or {}) do
  print(schema.name)
end

list_tables

List all tables within a Snowflake database schema.

Parameters

NameTypeRequiredDescription
databasestringyesThe database name
schemastringyesThe schema name

Example

local result = app.integrations.snowflake.list_tables({
  database = "ANALYTICS",
  schema = "PUBLIC"
})

for _, tbl in ipairs(result.data or {}) do
  print(tbl.name .. " (" .. (tbl.kind or "unknown") .. ")")
end

describe_table

Get column definitions and metadata for a table.

Parameters

NameTypeRequiredDescription
databasestringyesThe database name
schemastringyesThe schema name
tablestringyesThe table name

Example

local result = app.integrations.snowflake.describe_table({
  database = "ANALYTICS",
  schema = "PUBLIC",
  table = "orders"
})

for _, col in ipairs(result.columns or {}) do
  print(col.name .. " (" .. col.type .. ")")
end

list_warehouses

List all warehouses in the Snowflake account.

Parameters

None.

Example

local result = app.integrations.snowflake.list_warehouses({})

for _, wh in ipairs(result.data or {}) do
  print(wh.name .. " — " .. (wh.size or "unknown") .. " — " .. (wh.state or "unknown"))
end

get_warehouse

Get details for a specific Snowflake warehouse.

Parameters

NameTypeRequiredDescription
namestringyesThe warehouse name

Example

local result = app.integrations.snowflake.get_warehouse({
  name = "COMPUTE_WH"
})

print("Warehouse: " .. result.name)
print("Size: " .. (result.size or "unknown"))
print("State: " .. (result.state or "unknown"))
print("Auto-suspend: " .. tostring(result.auto_suspend))

get_current_user

Get the current authenticated Snowflake user and session information.

Parameters

None.

Example

local result = app.integrations.snowflake.get_current_user({})

print("User: " .. (result.userName or result.user or "unknown"))
print("Account: " .. (result.account or "unknown"))

Multi-Account Usage

If you have multiple Snowflake accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.snowflake.function_name({...})

-- Explicit default (portable across setups)
app.integrations.snowflake.default.function_name({...})

-- Named accounts
app.integrations.snowflake.production.function_name({...})
app.integrations.snowflake.staging.function_name({...})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# Snowflake — Lua API Reference

## execute_query

Execute a SQL statement on Snowflake. Returns column metadata and result rows.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `sql` | string | yes | The SQL statement to execute |
| `warehouse` | string | no | Warehouse to use for the query |
| `database` | string | no | Database context for the query |
| `schema` | string | no | Schema context for the query |

### Examples

### Simple SELECT query

```lua
local result = app.integrations.snowflake.execute_query({
  sql = "SELECT CURRENT_TIMESTAMP(), CURRENT_DATABASE()"
})

for _, row in ipairs(result.rows) do
  print("Timestamp: " .. row[1])
end
```

### Query with context

```lua
local result = app.integrations.snowflake.execute_query({
  sql = "SELECT * FROM orders LIMIT 10",
  warehouse = "COMPUTE_WH",
  database = "SALES_DB",
  schema = "PUBLIC"
})

for _, row in ipairs(result.rows) do
  print(row.id .. ": " .. row.status)
end
```

### Aggregation query

```lua
local result = app.integrations.snowflake.execute_query({
  sql = "SELECT COUNT(*) as total, SUM(amount) as revenue FROM sales WHERE year = 2026",
  warehouse = "ANALYTICS_WH",
  database = "ANALYTICS"
})

for _, row in ipairs(result.rows) do
  print("Total: " .. row.total .. ", Revenue: " .. row.revenue)
end
```

---

## list_databases

List all databases in the Snowflake account.

### Parameters

None.

### Example

```lua
local result = app.integrations.snowflake.list_databases({})

for _, db in ipairs(result.data or {}) do
  print(db.name)
end
```

---

## get_database

Get details for a specific Snowflake database.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `database` | string | yes | The database name or identifier |

### Example

```lua
local result = app.integrations.snowflake.get_database({
  database = "ANALYTICS"
})

print("Database: " .. result.name)
print("Owner: " .. (result.owner or "unknown"))
```

---

## list_schemas

List all schemas within a Snowflake database.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `database` | string | yes | The database name |

### Example

```lua
local result = app.integrations.snowflake.list_schemas({
  database = "ANALYTICS"
})

for _, schema in ipairs(result.data or {}) do
  print(schema.name)
end
```

---

## list_tables

List all tables within a Snowflake database schema.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `database` | string | yes | The database name |
| `schema` | string | yes | The schema name |

### Example

```lua
local result = app.integrations.snowflake.list_tables({
  database = "ANALYTICS",
  schema = "PUBLIC"
})

for _, tbl in ipairs(result.data or {}) do
  print(tbl.name .. " (" .. (tbl.kind or "unknown") .. ")")
end
```

---

## describe_table

Get column definitions and metadata for a table.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `database` | string | yes | The database name |
| `schema` | string | yes | The schema name |
| `table` | string | yes | The table name |

### Example

```lua
local result = app.integrations.snowflake.describe_table({
  database = "ANALYTICS",
  schema = "PUBLIC",
  table = "orders"
})

for _, col in ipairs(result.columns or {}) do
  print(col.name .. " (" .. col.type .. ")")
end
```

---

## list_warehouses

List all warehouses in the Snowflake account.

### Parameters

None.

### Example

```lua
local result = app.integrations.snowflake.list_warehouses({})

for _, wh in ipairs(result.data or {}) do
  print(wh.name .. " — " .. (wh.size or "unknown") .. " — " .. (wh.state or "unknown"))
end
```

---

## get_warehouse

Get details for a specific Snowflake warehouse.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | The warehouse name |

### Example

```lua
local result = app.integrations.snowflake.get_warehouse({
  name = "COMPUTE_WH"
})

print("Warehouse: " .. result.name)
print("Size: " .. (result.size or "unknown"))
print("State: " .. (result.state or "unknown"))
print("Auto-suspend: " .. tostring(result.auto_suspend))
```

---

## get_current_user

Get the current authenticated Snowflake user and session information.

### Parameters

None.

### Example

```lua
local result = app.integrations.snowflake.get_current_user({})

print("User: " .. (result.userName or result.user or "unknown"))
print("Account: " .. (result.account or "unknown"))
```

---

## Multi-Account Usage

If you have multiple Snowflake accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.snowflake.function_name({...})

-- Explicit default (portable across setups)
app.integrations.snowflake.default.function_name({...})

-- Named accounts
app.integrations.snowflake.production.function_name({...})
app.integrations.snowflake.staging.function_name({...})
```

All functions are identical across accounts — only the credentials differ.

Metadata-Derived Lua Example

local result = app.integrations.snowflake.snowflake_execute_query({
  sql = "example_sql",
  warehouse = "example_warehouse",
  database = "example_database",
  schema = "example_schema"
})
print(result)

Functions

snowflake_execute_query

Execute a SQL statement on Snowflake. Returns column metadata and result rows. Optionally specify warehouse, database, and schema context.

Operation
Write write
Full name
snowflake.snowflake_execute_query
ParameterTypeRequiredDescription
sql string yes The SQL statement to execute (e.g., "SELECT * FROM my_table LIMIT 10").
warehouse string no The warehouse to use for the query (overrides default).
database string no The database context for the query.
schema string no The schema context for the query.

snowflake_list_databases

List all databases in the Snowflake account. Returns database names, identifiers, and creation timestamps.

Operation
Read read
Full name
snowflake.snowflake_list_databases
ParameterTypeRequiredDescription
No parameters.

snowflake_get_database

Get details for a specific Snowflake database, including retention time, owner, and size.

Operation
Read read
Full name
snowflake.snowflake_get_database
ParameterTypeRequiredDescription
database string yes The database name or identifier.

snowflake_list_schemas

List all schemas within a Snowflake database. Returns schema names and metadata.

Operation
Read read
Full name
snowflake.snowflake_list_schemas
ParameterTypeRequiredDescription
database string yes The database name to list schemas from.

snowflake_list_tables

List all tables within a Snowflake database schema. Returns table names, types, and metadata.

Operation
Read read
Full name
snowflake.snowflake_list_tables
ParameterTypeRequiredDescription
database string yes The database name.
schema string yes The schema name within the database.

snowflake_describe_table

Describe a Snowflake table — get column names, data types, nullable, default values, and other metadata.

Operation
Read read
Full name
snowflake.snowflake_describe_table
ParameterTypeRequiredDescription
database string yes The database name.
schema string yes The schema name.
table string yes The table name.

snowflake_list_warehouses

List all warehouses in the Snowflake account. Returns warehouse names, sizes, and status.

Operation
Read read
Full name
snowflake.snowflake_list_warehouses
ParameterTypeRequiredDescription
No parameters.

snowflake_get_warehouse

Get details for a specific Snowflake warehouse, including size, type, auto-suspend, and auto-resume settings.

Operation
Read read
Full name
snowflake.snowflake_get_warehouse
ParameterTypeRequiredDescription
name string yes The warehouse name.

snowflake_get_current_user

Get the current authenticated Snowflake user and session information.

Operation
Read read
Full name
snowflake.snowflake_get_current_user
ParameterTypeRequiredDescription
No parameters.