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_ICEBERGin 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 theURL =>parameter name specifier.
LOCATION, and setting MAX_STALENESS, see Best practices in the Iceberg guide.
Examples
Simplifying queries with views
You can wrapREAD_ICEBERG TVFs in a view for easier querying of Iceberg tables. This also works with LOCATION-based READ_ICEBERG calls.
READ_ICEBERG directly:
Reading using a LOCATION
The following code example reads the first 5 rows from an Iceberg table using aLOCATION 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:Using a direct path to a metadata.json file
A URL pointing to an Iceberg metadata.json file will also return the same result:Authenticated read from S3
The following code examples use various valid combinations of AWS secrets to read from S3: Using access key + secret: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.
Reading from REST
The following code example reads the first 5 rows from an Iceberg table in a REST catalog: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 customOAUTH_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:
BEARER_TOKEN parameter.
Reading from Snowflake Open Catalog
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, thewarehouse parameter maps to catalog_id and the namespace parameter maps to database:
About Metadata Versions in File-Based Catalogs
When reading from a file-based catalog, Firebolt first looks for aversion-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.