Skip to main content
For an overview of querying, tuning, and exporting Iceberg tables, see the Iceberg guide. A table-valued function (TVF) that reads data from Apache Iceberg tables. The function can use either a location object or individual TVF parameters to access the data, and can read from file-based catalogs as well as REST catalogs. READ_ICEBERG returns a table with data from the specified Iceberg table.

Syntax

Parameters

Using a LOCATION object

For a comprehensive guide to LOCATION objects, see LOCATION objects. For syntax details, see CREATE LOCATION (Iceberg).

Using individual TVF parameters

Common Parameters

Common Parameters for Iceberg REST catalogs

The following parameters are used for all REST catalogs, including AWS Glue catalogs accessed via REST endpoint.

Amazon S3 Parameters

The following parameters are used for authentication to both file-based catalogs and AWS Glue catalogs.

Parameters for OAuth authentication

The following parameters apply to REST catalogs that use OAuth for authentication.

Return Type

The result is a table with data from the Iceberg files. Columns are read and parsed using their inferred data types.

Best practices

  • Use views to simplify repeated queries. Wrap READ_ICEBERG in a view so you can query Iceberg tables without repeating the TVF call. See example below.
  • It is recommended to specify all parameters using the named-parameter syntax rather than relying on parameter positions. For example: use URL => 'http://example.com' rather than omitting the URL => parameter name specifier.
For best practices that apply to all Iceberg access in Firebolt, such as choosing between access methods, storing credentials in a LOCATION, and setting MAX_STALENESS, see Best practices in the Iceberg guide.

Examples

Simplifying queries with views

You can wrap READ_ICEBERG TVFs in a view for easier querying of Iceberg tables. This also works with LOCATION-based READ_ICEBERG calls.
Once views are created, you can use them in joins and complex queries without referencing READ_ICEBERG directly:
For more information about views, see CREATE VIEW.

Reading using a LOCATION

The following code example reads the first 5 rows from an Iceberg table using a LOCATION object:
LOCATION objects are supported for file-based (S3-hosted) catalogs as well as REST catalogs. For more examples of LOCATION, see CREATE LOCATION (Iceberg).

Using TVF parameters, from a public location in S3

The following code example reads the first 5 rows from an Iceberg table in a file-based catalog stored on S3:
Returns

Using a direct path to a metadata.json file

A URL pointing to an Iceberg metadata.json file will also return the same result:
Returns

Authenticated read from S3

The following code examples use various valid combinations of AWS secrets to read from S3: Using access key + secret:
Using access key, secret, and session token:
Using role + external id (recommended):
For role-based AWS access you can additionally set an external ID. An external ID is a value you choose and control that AWS checks when Firebolt assumes your role, adding a second condition on top of your account’s unique IAM principal. Configuring one is a recommended best practice. See IAM roles.
Using role only:

Reading from REST

The following code example reads the first 5 rows from an Iceberg table in a REST catalog:
For more on Iceberg REST catalogs, see the Iceberg REST API spec.

Reading from REST, with a custom OAuth token URL

Some Iceberg REST catalogs do not support the /v1/oauth/tokens API, and serve OAuth tokens from a different API. For these catalogs, specify OAUTH_SERVER_URL.

Reading from Databricks Unity Catalog

One example of an Iceberg REST catalog that requires a custom OAUTH_SERVER_URL is the Databricks Unity Catalog. The following code example reads the first 5 rows from a table in a Databricks Unity Catalog, showing how Databricks concepts map to READ_ICEBERG parameters:
If you’re using a PAT Databricks - Authenticate with Databricks personal access tokens (legacy), you can pass it via the BEARER_TOKEN parameter.
For configuring Unity Catalog in your Databricks workspace, see Databricks - Set up and manage Unity Catalog. Note that you will need to enable credential vending in your Unity Catalog, see Databricks - Unity Catalog credential vending for external system access. For general information about reading Databricks tables from Iceberg clients, see Databricks - Read Databricks tables from Iceberg clients.

Reading from Snowflake Open Catalog

For setting up a Snowflake Open Catalog in your account, see Snowflake - Snowflake Open Catalog overview. Note that you will need to enable credential vending for your Iceberg tables, see Snowflake - Use catalog-vended credentials for Apache Iceberg™ tables. For general information about reading Snowflake Open Catalog tables from Iceberg clients, see Snowflake - Checking your REST catalog configuration.

Reading from AWS Glue catalog

The following code example reads the first 5 rows from an Iceberg table in an AWS Glue catalog. Note that for AWS Glue catalogs, the warehouse parameter maps to catalog_id and the namespace parameter maps to database:
Firebolt supports authentication using either Lake Formation or direct access to underlying storage. For authentication details, refer to the AWS Glue Catalog section in CREATE LOCATION (Iceberg).

About Metadata Versions in File-Based Catalogs

When reading from a file-based catalog, Firebolt first looks for a version-hint.text file to determine the metadata version. If this file is unavailable, you can instead specify a direct path to a specific metadata.json file.
Alternatively, Firebolt can also attempt to ‘guess’ the correct metadata file. Because this approach may violate atomicity guarantees, it is disabled by default. For details, see Guessing Iceberg metadata version.