KosmoKrator

data

Snowflake Lua API for KosmoKrator Agents

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

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.

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic Snowflake workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.snowflake.execute_query({sql = "example_sql", warehouse = "example_warehouse", database = "example_database", schema = "example_schema"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("snowflake"))' --json
kosmo integrations:lua --eval 'print(docs.read("snowflake.execute_query"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

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

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.snowflake, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.snowflake.default.* or app.integrations.snowflake.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Snowflake, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

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.execute_query({sql = "example_sql", warehouse = "example_warehouse", database = "example_database", schema = "example_schema"})
print(result)

Functions

execute_query Write

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

Lua path
app.integrations.snowflake.execute_query
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.
list_databases Read

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

Lua path
app.integrations.snowflake.list_databases
Full name
snowflake.snowflake_list_databases
ParameterTypeRequiredDescription
No parameters.
get_database Read

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

Lua path
app.integrations.snowflake.get_database
Full name
snowflake.snowflake_get_database
ParameterTypeRequiredDescription
database string yes The database name or identifier.
list_schemas Read

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

Lua path
app.integrations.snowflake.list_schemas
Full name
snowflake.snowflake_list_schemas
ParameterTypeRequiredDescription
database string yes The database name to list schemas from.
list_tables Read

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

Lua path
app.integrations.snowflake.list_tables
Full name
snowflake.snowflake_list_tables
ParameterTypeRequiredDescription
database string yes The database name.
schema string yes The schema name within the database.
describe_table Read

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

Lua path
app.integrations.snowflake.describe_table
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.
list_warehouses Read

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

Lua path
app.integrations.snowflake.list_warehouses
Full name
snowflake.snowflake_list_warehouses
ParameterTypeRequiredDescription
No parameters.
get_warehouse Read

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

Lua path
app.integrations.snowflake.get_warehouse
Full name
snowflake.snowflake_get_warehouse
ParameterTypeRequiredDescription
name string yes The warehouse name.
get_current_user Read

Get the current authenticated Snowflake user and session information.

Lua path
app.integrations.snowflake.get_current_user
Full name
snowflake.snowflake_get_current_user
ParameterTypeRequiredDescription
No parameters.