--- title: Iceberg --- ## Overview This code block demonstrates how to query an Iceberg table. ```sql CREATE FOREIGN DATA WRAPPER HANDLER iceberg_fdw_handler VALIDATOR iceberg_fdw_validator; CREATE SERVER FOREIGN DATA WRAPPER ; CREATE FOREIGN TABLE () SERVER OPTIONS (files ''); ``` ```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'); ```` Foreign data wrapper name. Can be any string. Foreign server name. Can be any string. Foreign table name. Can be any string. 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. ## 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 `.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.