> ## Documentation Index
> Fetch the complete documentation index at: https://deepline.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Redshift: Actions/run Query

> Running an ad hoc SQL query against a public or already-routed Redshift endpoint using password or IAM temporary database credentials.

Running an ad hoc SQL query against a public or already-routed Redshift endpoint using password or IAM temporary database credentials.

<Info>
  Tool ID: `redshift_run_query`
</Info>

## Run this action

Use the TypeScript SDK for a single call. Put `ctx.tools.execute(...)` inside a Play when the call should be durable, scheduled, or run across a CSV.

```ts theme={null}
import { Deepline } from 'deepline';

const deepline = await Deepline.connect();
const result = await deepline.tools.execute(
  'redshift_run_query',
  {
    "query": "software companies hiring engineers"
  },
);

console.log(result.toolResponse.raw);
```

### CLI

```bash theme={null}
deepline tools execute redshift_run_query --input '{
  "query": "software companies hiring engineers"
}' --json
```

## Example response

The SDK exposes this shape at `result.toolResponse.raw`. Values below are representative.

```json theme={null}
{
  "data": {
    "rows": [
      {}
    ],
    "rowCount": 123,
    "limited": true,
    "columns": [
      "example"
    ],
    "queryId": "query_123"
  }
}
```

Use `deepline tools get redshift_run_query --json` for the latest machine-readable contract.

## Input reference

| Name                  | Type      | Required | Default  | Details                                                                                                                                                                                                         |
| --------------------- | --------- | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `payload.credentials` | `object`  | No       | —        | —                                                                                                                                                                                                               |
| `payload.query`       | `string`  | Yes      | —        | SQL query text to execute. Defaults to read-only SELECT or WITH statements; set write: true for a single mutating or DDL statement.                                                                             |
| `payload.binds`       | `array`   | No       | —        | Optional positional bind values for parameterized SQL.                                                                                                                                                          |
| `payload.timeoutMs`   | `integer` | No       | `120000` | Redshift statement timeout in milliseconds. Default 120000.                                                                                                                                                     |
| `payload.rowLimit`    | `integer` | No       | `5000`   | Maximum number of rows to return. Default 5000.                                                                                                                                                                 |
| `payload.write`       | `boolean` | No       | `false`  | Explicitly opt into executing one non-read-only SQL statement. Required for INSERT, MERGE, UPDATE, DELETE, CREATE, ALTER, DROP, or other statements that may modify or overwrite customer data. Defaults false. |

<details>
  <summary>Show raw input schema</summary>

  ### Input JSON Schema

  ```json theme={null}
  {
    "type": "object",
    "description": "",
    "properties": {
      "credentials": {
        "type": "object",
        "properties": {
          "auth_type": {
            "type": "string",
            "enum": [
              "password",
              "iam"
            ]
          },
          "host": {
            "type": "string",
            "description": "Public or already-routed Redshift endpoint hostname."
          },
          "port": {
            "type": "integer",
            "default": 5439
          },
          "database": {
            "type": "string",
            "description": "Default database."
          },
          "schema": {
            "type": "string",
            "description": "Default schema. Defaults to public."
          },
          "user": {
            "type": "string",
            "description": "Database user. Required for password and provisioned-cluster IAM auth."
          },
          "password": {
            "type": "string",
            "description": "Password auth secret."
          },
          "region": {
            "type": "string",
            "description": "AWS region for IAM database credential exchange."
          },
          "access_key_id": {
            "type": "string",
            "description": "AWS access key ID for IAM auth."
          },
          "secret_access_key": {
            "type": "string",
            "description": "AWS secret access key for IAM auth."
          },
          "session_token": {
            "type": "string",
            "description": "Optional AWS session token."
          },
          "cluster_identifier": {
            "type": "string",
            "description": "Provisioned cluster identifier. Mutually exclusive with workgroup_name."
          },
          "workgroup_name": {
            "type": "string",
            "description": "Serverless workgroup name. Mutually exclusive with cluster_identifier."
          }
        },
        "required": [
          "host",
          "database"
        ],
        "additionalProperties": false
      },
      "query": {
        "type": "string",
        "description": "SQL query text to execute. Defaults to read-only SELECT or WITH statements; set write: true for a single mutating or DDL statement."
      },
      "binds": {
        "type": "array",
        "description": "Optional positional bind values for parameterized SQL.",
        "items": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "number"
            },
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "timeoutMs": {
        "type": "integer",
        "description": "Redshift statement timeout in milliseconds. Default 120000.",
        "default": 120000
      },
      "rowLimit": {
        "type": "integer",
        "description": "Maximum number of rows to return. Default 5000.",
        "default": 5000
      },
      "write": {
        "type": "boolean",
        "description": "Explicitly opt into executing one non-read-only SQL statement. Required for INSERT, MERGE, UPDATE, DELETE, CREATE, ALTER, DROP, or other statements that may modify or overwrite customer data. Defaults false.",
        "default": false
      }
    },
    "required": [
      "query"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Output reference

Redshift query result.

| Name                                 | Type               | Required | Default | Details                                        |
| ------------------------------------ | ------------------ | -------- | ------- | ---------------------------------------------- |
| `result.data`                        | `object`           | Yes      | —       | Provider response payload.                     |
| `result.data.rows`                   | `array`            | Yes      | —       | —                                              |
| `result.data.rowCount`               | `integer`          | Yes      | —       | —                                              |
| `result.data.limited`                | `boolean`          | Yes      | —       | —                                              |
| `result.data.columns`                | `array`            | Yes      | —       | —                                              |
| `result.data.queryId`                | `string \| null`   | Yes      | —       | —                                              |
| `result.data.dataset`                | `object`           | No       | —       | —                                              |
| `result.data.dataset.kind`           | `"redshift_query"` | Yes      | —       | —                                              |
| `result.data.dataset.total_rows`     | `integer`          | Yes      | —       | —                                              |
| `result.data.dataset.returned_limit` | `integer`          | Yes      | —       | —                                              |
| `result.data.dataset.offset`         | `integer`          | Yes      | —       | —                                              |
| `result.data.dataset.page_size`      | `integer`          | Yes      | —       | —                                              |
| `result.meta`                        | `record`           | No       | —       | Additional response metadata (status, paging). |

<details>
  <summary>Show raw output schema</summary>

  ### Output JSON Schema

  ```json theme={null}
  {
    "type": "object",
    "description": "Redshift query result.",
    "properties": {
      "data": {
        "type": "object",
        "description": "Provider response payload.",
        "properties": {
          "rows": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {}
            }
          },
          "rowCount": {
            "type": "integer"
          },
          "limited": {
            "type": "boolean"
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "queryId": {
            "type": [
              "string",
              "null"
            ]
          },
          "dataset": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string",
                "const": "redshift_query"
              },
              "total_rows": {
                "type": "integer"
              },
              "returned_limit": {
                "type": "integer"
              },
              "offset": {
                "type": "integer"
              },
              "page_size": {
                "type": "integer"
              }
            },
            "required": [
              "kind",
              "total_rows",
              "returned_limit",
              "offset",
              "page_size"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "rows",
          "rowCount",
          "limited",
          "columns",
          "queryId"
        ],
        "additionalProperties": false
      },
      "meta": {
        "type": "object",
        "description": "Additional response metadata (status, paging).",
        "additionalProperties": {}
      }
    },
    "required": [
      "data"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Deepline cost

* Pricing model: `fixed` (per call).
* Estimated Deepline credits: `0` per pricing unit.
* Provider-native pricing may still exist outside Deepline credit billing.

## Related documentation

* [Redshift provider guide](/docs/providers/redshift/guide)
* [SDK V2 quickstart](/docs/sdk-v2/quickstart)
* [SDK reference](/docs/sdk-v2/sdk-reference)
* [Run tools across a CSV](/docs/sdk-v2/batch-csv)
