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

# Connect VeloDB or Apache Doris as a destination

> Create a VeloDB or Apache Doris user for Artie, open the ports Artie loads through, and connect the cluster to an Artie pipeline as a destination.

VeloDB / Apache Doris appears in the dashboard once Artie turns it on for your company. Contact Artie support to turn it on.

Artie works with Apache Doris 2.1.8 or later, or 3.0.4 or later. Earlier Doris versions have merge-on-write bugs that can bring back deleted rows or duplicate keys.

## Required settings

Artie asks for these values. Each field name matches its label in the Artie dashboard.

| Field                | What to enter                                                                       |
| -------------------- | ----------------------------------------------------------------------------------- |
| **Host**             | A frontend (FE) node, or the load balancer in front of the frontends.               |
| **Query port**       | The frontends' MySQL protocol port. The default is `9030`.                          |
| **Stream Load port** | The frontends' HTTP port. The default is `8030`.                                    |
| **Username**         | The user Artie writes with, `artie` in the [user script](#create-a-user-for-artie). |
| **Password**         | The user's password.                                                                |
| **Disable TLS**      | Off by default. See [TLS](#tls).                                                    |
| **Database name**    | The database Artie writes to.                                                       |

### Create a user for Artie

On a cluster with one backend (BE) node, create the destination database yourself first. Doris keeps 3 replicas by default and can't create tables in the database otherwise. Connect to a frontend with a MySQL client and run:

```sql
CREATE DATABASE DATABASE_NAME
PROPERTIES ("replication_allocation" = "tag.location.default:1");
```

Then run this script to create the user. It grants `CREATE`, `ALTER`, `LOAD`, `DROP` and `SELECT` on the destination database:

```sql
CREATE USER 'artie'@'%' IDENTIFIED BY 'PASSWORD';

GRANT SELECT_PRIV, LOAD_PRIV, ALTER_PRIV, CREATE_PRIV, DROP_PRIV
ON internal.DATABASE_NAME.* TO 'artie'@'%';
```

Replace `PASSWORD` with the user's password, and `DATABASE_NAME` with your destination database.

### Open the ports

Artie creates tables over the query port and loads rows with Stream Load. Each frontend redirects a Stream Load request to a backend, so Artie must reach these ports:

* The frontends' query port, `9030` by default.
* The frontends' Stream Load port, `8030` by default.
* The backends' HTTP port, `8040` by default.

On a data plane that Artie hosts, Stream Load only connects to public IP addresses. The host and every backend must resolve to public addresses. This limit doesn't apply when the pipeline runs on a [bring your own cloud (BYOC)](/docs/glossary#byoc-bring-your-own-cloud) data plane.

VeloDB / Apache Doris destinations don't support SSH tunnels. If your cluster limits inbound traffic, allow [Artie's IP addresses](/docs/connection-options) for your data plane's region.

### TLS

With **Disable TLS** off, Artie connects to the query port with TLS and sends Stream Load requests over HTTPS. Your backends must then serve Stream Load over HTTPS too, because Artie doesn't follow a frontend's redirect from HTTPS to HTTP. Artie checks the server's TLS certificate, so a self-signed certificate fails.

With **Disable TLS** on, Artie connects to both ports without TLS. Turn TLS off only on a private network.

### VeloDB Cloud

Whether a VeloDB Cloud public endpoint supports TLS depends on the warehouse's version and settings. See [VeloDB's public endpoint docs](https://docs.velodb.io/cloud/management-guide/connection/public-link). Without TLS, the password and rows cross the internet unencrypted.

If your warehouse's public endpoint has no TLS, connect over a private network that you set up. A data plane that Artie hosts loads only to public addresses, so run the pipeline on a [BYOC](/docs/glossary#byoc-bring-your-own-cloud) data plane.

## Add VeloDB to a pipeline

When you create a pipeline, the **Destination** section of the setup has these steps.

**Step 1: Choose the destination**

In **Choose destination**, select **VeloDB / Apache Doris**.

**Step 2: Prepare the cluster**

**Prepare destination** shows the supported versions, the ports and the grants. Do the steps in [Create a user for Artie](#create-a-user-for-artie) and [Open the ports](#open-the-ports), then select **Continue**.

When the pipeline reuses an existing VeloDB / Apache Doris connector, this step shows as done and the setup skips it.

**Step 3: Enter the connection details**

In **Connect and verify**, enter **Host**, **Query port**, **Stream Load port**, **Username** and **Password**. Set **Disable TLS** as [TLS](#tls) describes.

**Step 4: Choose the database**

In **Database name**, select the database Artie writes to.

To create a database, type its name and select **Create “NAME”**, where `NAME` is the name you typed. In the **Add a new database** dialog, select **Create database**. Creating a database needs `CREATE_PRIV` on it. Doris gives its tables 3 replicas, so on a cluster with one backend, create the database as [Create a user for Artie](#create-a-user-for-artie) shows.

**Step 5: Verify the destination**

Select **Verify destination**. Artie creates a test table, adds a column, loads one row with Stream Load and drops the table. A passing check shows "Destination verified".

If you haven't chosen tables yet, the button reads **Test connection**. A passing test shows "Connection works. Choose tables to finish verifying the destination."

The setup has no **Network access** step for VeloDB / Apache Doris, because these destinations don't support SSH tunnels.

To change these settings on an existing pipeline, select **Edit pipeline**, then open the **Destination: VeloDB / Apache Doris** tab.

## What Artie creates

Artie creates its destination tables in the database you chose. It loads rows straight into them with Stream Load, without staging tables.

| Table                                                     | Doris table model                                                                                  |
| --------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| Replicated table with a primary key or merge key          | `UNIQUE KEY` on those columns, with merge-on-write and `__artie_updated_at` as the sequence column |
| Replicated table with neither, or an append-only table    | `DUPLICATE KEY`                                                                                    |
| [History mode](/docs/pipelines/tables#history-mode) table | `DUPLICATE KEY`                                                                                    |

A `UNIQUE KEY` table holds one row per key. Its sequence column makes Doris keep the row with the latest `__artie_updated_at`, so a load that arrives late can't overwrite a newer row. A `DUPLICATE KEY` table keeps every row Artie loads.

**Add 'Artie updated at' column** is always on for VeloDB / Apache Doris, and you can't rename the column. Artie also refuses to exclude, hash or encrypt `__artie_updated_at`. See [System columns](/docs/pipelines/system-columns).

When a row is deleted in the source, Artie deletes it from a `UNIQUE KEY` table. A `DUPLICATE KEY` table keeps the row. With [soft deletes](/docs/pipelines/system-columns#soft-delete-columns) on, Artie keeps the row and sets `__artie_delete` to true.

A destination table name can have at most 64 characters and can't contain a backtick.

### Data types

Artie maps its own types to these Doris types. [Artie's typing library](/docs/guides/artie/arties-typing-library) covers how source types become Artie types.

| Artie type                                                      | Doris type                  |
| --------------------------------------------------------------- | --------------------------- |
| Float, double                                                   | `DOUBLE`                    |
| Small integer                                                   | `SMALLINT`                  |
| Integer                                                         | `INT`                       |
| Big integer, or an integer of unknown size                      | `BIGINT`                    |
| Decimal with a precision up to 38 and a scale of 0 or more      | `DECIMAL(precision, scale)` |
| Decimal with a higher or unknown precision, or a negative scale | `STRING`                    |
| Boolean                                                         | `BOOLEAN`                   |
| Date                                                            | `DATE`                      |
| Timestamp, with or without a time zone                          | `DATETIME(6)`               |
| String, UUID, time, interval                                    | `STRING`                    |
| Bytes                                                           | `STRING`, as base64         |
| Array, struct or JSON                                           | `STRING`, as JSON text      |

Artie converts timestamps that have a time zone to UTC.

In a `UNIQUE KEY` table, a key column that would be `STRING` or `DOUBLE` is `VARCHAR(65533)` instead, because Doris doesn't allow those types in a key.