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

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/iceberg/partitioning/iceberg_truncate",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Truncate value to a width according to Iceberg partition transforms

# ICEBERG_TRUNCATE

Truncates a value to a specified width, according to the [Iceberg partition transforms specification](https://iceberg.apache.org/spec/#partition-transforms).

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
ICEBERG_TRUNCATE(<value>, <width>)
```

## Parameters

| Parameter | Description                                        | Supported input types                |
| :-------- | :------------------------------------------------- | :----------------------------------- |
| `<value>` | The value to truncate.                             | `INTEGER`, `BIGINT`, `TEXT`, `BYTEA` |
| `<width>` | The truncation width. Must be a positive constant. | `BIGINT`                             |

## Return type

Returns the same type as the input `<value>`:

* `INTEGER` for `INTEGER` input
* `BIGINT` for `BIGINT` input
* `TEXT` for `TEXT` input
* `BYTEA` for `BYTEA` input

## Remarks

The `ICEBERG_TRUNCATE` function can be used in the `PARTITION BY` clause of [`CREATE ICEBERG TABLE`](/reference-sql/commands/data-definition/create-iceberg-table-as-select) commands.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
CREATE ICEBERG TABLE events
  PARTITION BY (iceberg_truncate(category, 3))
  AS SELECT * FROM source_events
WITH LOCATION = my_iceberg_location;
```

The truncation behavior depends on the input type:

**For integers (`INTEGER`, `BIGINT`):** Returns the largest multiple of `width` that is less than or equal to the value. For negative values, this rounds toward negative infinity.

**For strings (`TEXT`):** Returns the first `width` Unicode code points of the string. If the string is shorter than `width`, returns the original string unchanged.

**For binary (`BYTEA`):** Returns the first `width` bytes of the binary data. If the data is shorter than `width`, returns the original data unchanged.

The `<width>` parameter must be a positive constant value. Using zero, negative values, or non-constant expressions results in an error.

## Example

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT iceberg_truncate(12345, 100) AS truncated_partition;
```

**Returns:**

| truncated\_partition |
| :------------------- |
| 12300                |
