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

# Teradata

> Run queries on Teradata

## Overview

The Teradata tools allow you to run SQL queries on a Teradata database and to build and search vector stores on Teradata Vantage Cloud for RAG-style workflows.

## Key Features

* `TERADATA_RUN_QUERY`
  * Execute SQL queries on a Teradata database.
  * Retrieve results in a structured format.
* `VANTAGE_CLOUD_VECTOR_STORE_CREATE`
  * Create a VectorStore on Vantage Cloud from files in Jinba storage, with document ingestion and chunking.
* `VANTAGE_CLOUD_VECTOR_STORE_ADD_DOCUMENT`
  * Add documents from files in Jinba storage to an existing VectorStore on Vantage Cloud.
* `VANTAGE_CLOUD_VECTOR_SEARCH`
  * Perform semantic similarity search on a Vantage Cloud VectorStore.

## Authentication

For `TERADATA_RUN_QUERY`, you will need your Teradata database credentials: `host`, `user`, and `password`.

The three `VANTAGE_CLOUD_*` tools share the same config parameters:

| Parameter     | Required | Description                                                                                                                 |
| ------------- | -------- | --------------------------------------------------------------------------------------------------------------------------- |
| `host`        | No       | Vantage Cloud host address (default: `host.docker.internal`, keep the default when using an SSH tunnel on the host machine) |
| `dbs_port`    | No       | Database port number (default: `1025`)                                                                                      |
| `username`    | Yes      | Database username                                                                                                           |
| `password`    | Yes      | Database password                                                                                                           |
| `base_url`    | Yes      | UES URI (the URL without the trailing `/open-analytics`)                                                                    |
| `pat_token`   | Yes      | Personal Access Token (for CCP authentication)                                                                              |
| `pem_content` | Yes      | Contents of the PEM private key (paste the text starting with `-----BEGIN PRIVATE KEY-----` as-is)                          |
| `pem_kid`     | No       | Key ID of the PEM key (defaults to `username`; must match the key name registered on the Teradata side)                     |

**Note**: Treat API keys as sensitive information and never commit them to public repositories.

## Vantage Cloud Vector Tools

### VANTAGE\_CLOUD\_VECTOR\_STORE\_CREATE

Create a VectorStore on Vantage Cloud from files in Jinba storage.

**Input**:

| Parameter           | Type   | Required | Description                                                                                          |
| ------------------- | ------ | -------- | ---------------------------------------------------------------------------------------------------- |
| `vector_store_name` | string | Yes      | Name of the VectorStore to create                                                                    |
| `file_urls`         | string | Yes      | Comma-separated (or newline-separated) HTTPS URLs of files to ingest as documents (maximum 10 files) |
| `embeddings_model`  | string | No       | Embeddings model to use for vectorization (default: `amazon.titan-embed-text-v1`)                    |
| `search_algorithm`  | string | No       | Search algorithm: `VECTORDISTANCE` or `HNSW` (default: `VECTORDISTANCE`)                             |
| `top_k`             | number | No       | Number of top results for search (default: 5)                                                        |
| `object_names`      | string | No       | Object name for data storage (defaults to `vector_store_name` + `_data`)                             |
| `data_columns`      | string | No       | Data column name for text content (default: `chunks`)                                                |
| `vector_column`     | string | No       | Column name for vector embeddings (default: `Embedding`)                                             |
| `chunk_size`        | number | No       | Chunk size for document splitting (default: 500)                                                     |

**Output**: `result` with `name` (created VectorStore), `status`, and `message`.

### VANTAGE\_CLOUD\_VECTOR\_STORE\_ADD\_DOCUMENT

Add documents to an existing VectorStore on Vantage Cloud.

**Input**:

| Parameter           | Type   | Required | Description                                                                                       |
| ------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------- |
| `vector_store_name` | string | Yes      | Name of the existing VectorStore to add documents to                                              |
| `file_urls`         | string | Yes      | Comma-separated (or newline-separated) HTTPS URLs of files to add as documents (maximum 10 files) |

**Output**: `result` with `name`, `status`, and `message`.

### VANTAGE\_CLOUD\_VECTOR\_SEARCH

Perform semantic similarity search on a Vantage Cloud VectorStore.

**Input**:

| Parameter           | Type   | Required | Description                                      |
| ------------------- | ------ | -------- | ------------------------------------------------ |
| `vector_store_name` | string | Yes      | Name of the VectorStore to search                |
| `query`             | string | Yes      | Natural language query for similarity search     |
| `top_k`             | number | No       | Number of similar results to return (default: 5) |

**Output**: `result` with `similar_objects` (each containing `score` and, when available, `DataBaseName`, `TableName`, `TD_ID`, `TD_FILENAME`, `chunks`, `index_label`) and `total_count`.

### Example: Create a VectorStore and Search It

```yaml theme={null}
- id: create_vector_store
  tool: VANTAGE_CLOUD_VECTOR_STORE_CREATE
  config:
    - name: username
      value: "{{secrets.VANTAGE_USERNAME}}"
    - name: password
      value: "{{secrets.VANTAGE_PASSWORD}}"
    - name: base_url
      value: "{{secrets.VANTAGE_BASE_URL}}"
    - name: pat_token
      value: "{{secrets.VANTAGE_PAT_TOKEN}}"
    - name: pem_content
      value: "{{secrets.VANTAGE_PEM_CONTENT}}"
  input:
    - name: vector_store_name
      value: "product_docs"
    - name: file_urls
      value: "{{steps.upload_manual.result.file_url}}"

- id: vector_search
  tool: VANTAGE_CLOUD_VECTOR_SEARCH
  config:
    - name: username
      value: "{{secrets.VANTAGE_USERNAME}}"
    - name: password
      value: "{{secrets.VANTAGE_PASSWORD}}"
    - name: base_url
      value: "{{secrets.VANTAGE_BASE_URL}}"
    - name: pat_token
      value: "{{secrets.VANTAGE_PAT_TOKEN}}"
    - name: pem_content
      value: "{{secrets.VANTAGE_PEM_CONTENT}}"
  input:
    - name: vector_store_name
      value: "product_docs"
    - name: query
      value: "How do I reset my password?"
    - name: top_k
      value: 5
```

### Example: Run Teradata Query

```yaml theme={null}
- id: run_query
  tool: TERADATA_RUN_QUERY
  config:
    - name: host
      value: 100.21.165.28
    - name: user
      value: carnot
    - name: password
      value: carnot#123
  input:
    - name: query
      value: "

        \          with examples as (

        \              select 1 as id, 'jon' as name

        \              union all

        \              select 2 as id, 'jane' as name

        \          )

        \          select * from examples;

        \          "
```
