---
title: Iceberg
---

## Overview

This code block demonstrates how to query an Iceberg table.

```sql
CREATE FOREIGN DATA WRAPPER <wrapper_name>
HANDLER iceberg_fdw_handler
VALIDATOR iceberg_fdw_validator;

CREATE SERVER <server_name>
FOREIGN DATA WRAPPER <wrapper_name>;

CREATE FOREIGN TABLE <table_name> ()
SERVER <server_name>
OPTIONS (files '<files>');
```

<Accordion title="Example Usage">
```sql
CREATE FOREIGN DATA WRAPPER iceberg_wrapper
HANDLER iceberg_fdw_handler
VALIDATOR iceberg_fdw_validator;

CREATE SERVER iceberg_server
FOREIGN DATA WRAPPER iceberg_wrapper;

CREATE FOREIGN TABLE iceberg_table ()
SERVER iceberg_server
OPTIONS (files 's3://bucket/folder');

````
</Accordion>

<ParamField body="wrapper_name" required>
  Foreign data wrapper name. Can be any string.
</ParamField>
<ParamField body="server_name" required>
  Foreign server name. Can be any string.
</ParamField>
<ParamField body="table_name" required>
  Foreign table name. Can be any string.
</ParamField>
<ParamField body="files" required>
The path to the Iceberg table. For instance, `s3://bucket/folder` if the Iceberg table is in Amazon S3 or
`/path/to/folder` if the Iceberg table is on the local file system.
</ParamField>

## Allow Moved Paths

The `allow_moved_paths` option ensures that some path resolution is performed, which allows scanning Iceberg tables that are moved.

```sql
CREATE FOREIGN TABLE iceberg_table ()
SERVER iceberg_server
OPTIONS (
    files 's3://bucket/folder',
    allow_moved_paths 'true'
);
````

## Linking to the Manifest File

If no `version-hint.text` file is found in the Iceberg metadata, the following error will be thrown:

```
Error: IO Error: Cannot open file "s3://⟨bucket⟩/⟨iceberg-table-folder⟩/metadata/version-hint.text": No such file or directory
```

Providing the path to the `<id>.metadata.json` manifest will circumvent this error.

```sql
CREATE FOREIGN TABLE iceberg_table ()
SERVER iceberg_server
OPTIONS (
    files 's3://⟨bucket⟩/⟨iceberg-table-folder⟩/metadata/⟨id⟩.metadata.json',
);
```

## Cloud Object Stores

The [object stores](/integrations/object_stores) documentation explains how to provide secrets and other credentials for
Iceberg tables stored in object stores like S3.
