---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://ydb.tech/docs/en/yql/reference/syntax/alter-transfer.md?version=v25.3
  - https://ydb.tech/docs/ru/yql/reference/syntax/alter-transfer.md?version=v25.3
  - href: en/yql/reference/syntax/alter-transfer.md
    type: text/markdown
    title: Markdown version
  - href: ../../../llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: en/core/yql/reference/syntax/alter-transfer.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

# ALTER TRANSFER

The `ALTER TRANSFER` statement modifies the parameters and state of a [transfer](https://ydb.tech/docs/en/concepts/transfer.md?version=v25.3) instance.

## Syntax {#syntax}

```yql
ALTER TRANSFER <name> [SET USING lambda | SET (option = value [, ...])]
```

where:

* `name` — the name of the transfer instance.
* `lambda` — the [lambda-function](#lambda) for message transformation. <!-- markdownlint-disable-line MD051 -->
* `SET (option = value [, ...])` — the transfer [parameters](#params).

### Parameters {#params}

* `STATE` — the transfer [state](https://ydb.tech/docs/en/concepts/transfer.md?version=v25.3#pause-and-resume). Possible values:

* `PAUSED` — pauses the transfer.
* `ACTIVE` — resumes a paused transfer.

* <!-- source: en/yql/reference/_includes/transfer_flush.md -->
  Table write batching parameters let you balance the latency of records appearing in the table against the resources required by the transfer. Batching parameters affect the processing of each topic partition independently. Change batching parameters with caution, as this can either improve or degrade message stream processing speed, and may even lead to a denial of service if the parameters are misconfigured. For example, writing to the table in small batches can overload the table and degrade its performance, while an excessively large batch size can cause the server to run out of available memory.

  *   `BATCH_SIZE_BYTES` — the batch size in bytes. Default: 8 MB.
  *   `FLUSH_INTERVAL` — the table write interval. Default: 60 seconds. Data is written to the table at this interval, even if the batch has not reached the size specified in the `BATCH_SIZE_BYTES` parameter.
  <!-- endsource: en/yql/reference/_includes/transfer_flush.md -->

## Permissions

Modifying a transfer requires the `ALTER SCHEMA` [permissions](https://ydb.tech/docs/en/yql/reference/syntax/grant.md?version=v25.3#permissions-list).

## Examples {#examples}

The following query modifies the message transformation [lambda-function](https://ydb.tech/docs/en/yql/reference/syntax/expressions.md?version=v25.3#lambda):

```yql
$new_lambda = ($msg) -> {
    return [
        <|
            partition: $msg._partition,
            offset: $msg._offset,
            message: CAST($msg._data || ' altered' AS Utf8)
        |>
    ];
};

ALTER TRANSFER my_transfer SET USING $new_lambda;
```

The following query pauses the transfer:

```yql
ALTER TRANSFER my_transfer SET (STATE = "PAUSED");
```

The following query modifies the batching parameters:

```yql
ALTER TRANSFER my_transfer SET (
    BATCH_SIZE_BYTES = 1048576,
    FLUSH_INTERVAL = Interval('PT60S')
);
```

<!-- source: en/yql/reference/_includes/transfer_lambda.md -->
## Lambda function {#lambda}

A message transformation [lambda function](https://ydb.tech/docs/en/yql/reference/syntax/expressions.md?version=v25.3#lambda) takes a single structured parameter containing the message from the topic and returns a list of structures corresponding to the table rows for insertion.

Example:

```yql
$lambda = ($msg) -> {
  return [
    <|
      column_1: $msg._create_timestamp,
      column_2: $msg._data
    |>
  ];
};
```

In this example:

* `$msg` — the message received from the topic.
* `column_1` and `column_2` — the names of the table columns.
* `$msg._create_timestamp` and `$msg._data` — the values that will be written to the table. The value types must match the table column types. For example, if the `column_2` table column has the `String` type, the type of `$msg._data` must also be `String`.

The following fields are available in a topic message:

| Attribute           | Value type     | Description                      |
|---------------------|----------------|----------------------------------|
| `_create_timestamp` | `Timestamp`    | Message creation time            |
| `_data`             | `String`       | Message body                     |
| `_offset`           | `Uint64`       | [Message offset](../../../concepts/glossary.md#offset) |
| `_partition`        | `Uint32`       | Message's [partition](../../../concepts/glossary.md#partition) number |
| `_producer_id`      | `String`       | [Producer](../../../concepts/glossary.md#producer) ID|
| `_seq_no`           | `Uint64`       | Message sequence number         |
| `_write_timestamp`  | `Timestamp`    | Message write time              |


### Testing lambda functions

To test a lambda function during development, you can simulate a topic message by passing a structure with the same fields that the transfer will provide. Example:

```yql
$lambda = ($msg) -> {
  return [
    <|
      offset: $msg._offset,
      data: $msg._data
    |>
  ];
};

$msg = <|
  _data: "value",
  _offset: CAST(1 AS Uint64),
  _partition: CAST(2 AS Uint32),
  _producer_id: "producer",
  _seq_no: CAST(3 AS Uint64)
|>;

SELECT $lambda($msg);
```

If a lambda function contains complex transformation logic, you can extract it into a separate lambda function to simplify testing.

```yql
$extract_value = ($data) -> {
  -- complex transformations
  return $data;
};

$lambda = ($msg) -> {
  return [
    <|
      column: $extract_value($msg._data)
    |>
  ];
};

-- You can test the extract_value lambda function like this

SELECT $extract_value('converted value');
```
<!-- endsource: en/yql/reference/_includes/transfer_lambda.md -->

## See Also

* [CREATE TRANSFER](https://ydb.tech/docs/en/yql/reference/syntax/create-transfer.md?version=v25.3)
* [DROP TRANSFER](https://ydb.tech/docs/en/yql/reference/syntax/drop-transfer.md?version=v25.3)
* [Data transfer](https://ydb.tech/docs/en/concepts/transfer.md?version=v25.3)
