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

# Apache Iceberg

> Read catalog tables and use supported Iceberg writes with confirmed publication.

How-to guide

The Iceberg connector reads tables through a configured catalog. It supports append, whole-table overwrite, update, delete, and merge when the table and catalog support the operation. Native writes produce Parquet data files.

## Before you start

Connect an existing catalog using [Catalog connections](https://docs.e6data.com/transformation/learn/connect.md). Prepare access to both its metadata service and the table's storage. A successful metadata connection test does not confirm permission to read or write data files.

Choose an existing private namespace and an unused table name. The examples use `demo.examples.connector_orders`. Replace it with your catalog, namespace, and private table name throughout the guide. Run the statements in one Workbench session.

The catalog must support table creation for the sample below. For an existing table, start with the read query and use only the operations its catalog allows.

## Create sample data and read it

This creates a small format v2 table. It has two rows and an amount total of `20.0`.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SET spark.sql.caseSensitive = true;

CREATE TABLE demo.examples.connector_orders (
  order_id BIGINT,
  amount DOUBLE
)
USING iceberg
TBLPROPERTIES ('format-version' = '2');

INSERT INTO demo.examples.connector_orders VALUES (1, 12.5), (2, 7.5);

SELECT order_id, amount
FROM demo.examples.connector_orders
ORDER BY order_id;
```

The schema comes from the catalog's Iceberg metadata. The engine reads the files selected by the table snapshot. Reading its storage directory as a plain Parquet folder does not apply Iceberg snapshot or delete semantics.

## Append rows

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
INSERT INTO demo.examples.connector_orders VALUES (3, 5.0);

SELECT COUNT(*) AS row_count FROM demo.examples.connector_orders;
```

Expect `3`. A new submission of the same append adds those rows again.

## Update and delete rows

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
UPDATE demo.examples.connector_orders
SET amount = 8.5
WHERE order_id = 2;

DELETE FROM demo.examples.connector_orders WHERE order_id = 3;

SELECT order_id, amount
FROM demo.examples.connector_orders
ORDER BY order_id;
```

Expect `(1, 12.5)` and `(2, 8.5)`. The connector uses table row identity and the target-read contract for these operations. The catalog and table version must permit the required changes.

## Merge rows

Use one source row per target key. This example updates order 2 and adds order 4.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
MERGE INTO demo.examples.connector_orders AS target
USING (VALUES (2, 9.0), (4, 6.0)) AS source(order_id, amount)
ON target.order_id = source.order_id
WHEN MATCHED THEN UPDATE SET amount = source.amount
WHEN NOT MATCHED THEN INSERT (order_id, amount)
VALUES (source.order_id, source.amount);

SELECT order_id, amount
FROM demo.examples.connector_orders
ORDER BY order_id;
```

Expect `(1, 12.5)`, `(2, 9.0)`, and `(4, 6.0)`.

## Overwrite the whole table

This replaces all current rows. Run it only on the private example table.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
INSERT OVERWRITE TABLE demo.examples.connector_orders
SELECT CAST(5 AS BIGINT) AS order_id, CAST(20.0 AS DOUBLE) AS amount;

SELECT * FROM demo.examples.connector_orders;
```

Expect one row, `(5, 20.0)`. This guide covers whole-table replacement. Partition and predicate overwrite have separate capability requirements.

## Options and table properties

| Setting | Meaning |
| - | - |
| Qualified table name | Identifies the catalog, namespace, and table. |
| `format-version` | Selects the Iceberg table format version during creation. New tables default to v3; this example chooses v2. |
| `PARTITIONED BY` | Defines supported table partition transforms during creation. |
| `write.target-file-size-bytes` | Sets a target data-file size for later writes. |
| `write.parquet.*` | Controls the supported Parquet layout and compression settings for Iceberg output. |

Use [TBLPROPERTIES](https://docs.e6data.com/transformation/sql/tblproperties.md) for accepted values, defaults, and full examples. These settings belong to Iceberg tables. They are separate from the options accepted by the direct Parquet file connector.

## Data types and limits

Iceberg field IDs and metadata define the table schema. A type supported by a SQL expression can still be rejected by a table writer. Keep inserted columns compatible with the destination schema. Use [SQL writes](https://docs.e6data.com/transformation/sql/writes.md) for supported statement forms.

Reads and writes support format v3. Native table maintenance is limited to format v2. Format upgrades cannot be reversed. Catalog services can expose a narrower set of table operations than the connector.

Creating a table and publishing its first write requires catalog creation and publication support. A staged new table accepts its initial append; later mutations apply after that table is published. Credentials delegated by a catalog must also be valid for the data-file operation.

The write is visible after its commit is confirmed. A sequence of SQL statements is not a multi-statement transaction. Read the table after each write when checking a result.

## Cleanup

Drop only the private table created for this guide. Follow the catalog's retention policy for its stored files.

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
DROP TABLE demo.examples.connector_orders;
```

## Related guides

* [Connect a catalog](https://docs.e6data.com/transformation/learn/connect.md)
* [Catalog and storage access](https://docs.e6data.com/transformation/concepts/data-access.md)
* [Writing data](https://docs.e6data.com/transformation/sql/writes.md)
* [Iceberg settings](https://docs.e6data.com/transformation/reference/configuration/iceberg.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.