> [!WARNING]
>
> **Preview**
>
>
> This feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
> [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

Querying an Apache Iceberg view lets you read curated, zero-copy results from
the underlying Iceberg tables by running the SQL definition stored in the
*Lakehouse runtime catalog*. Your compute engine loads the view
definition from the catalog, resolves every referenced table and nested view,
and then reads the data files in Cloud Storage.

You can query Iceberg views only from Iceberg-compatible open source engines
such as Spark and Trino. BigQuery doesn't support querying
Iceberg views.

## Before you begin

1.
   [Verify that billing is enabled for your Google Cloud project](https://docs.cloud.google.com/billing/docs/how-to/verify-billing-enabled.md.txt#confirm_billing_is_enabled_on_a_project).

2.


   Enable the BigLake API, if it is not already enabled.


   **Roles required to enable APIs**


   To enable APIs, you need the `serviceusage.services.enable` permission. If you
   created the project, then you likely already have this permission through the
   Owner role (`roles/owner`). Otherwise, you can get this permission through the
   Service Usage Admin role (`roles/serviceusage.serviceUsageAdmin`).
   [Learn how to grant roles](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).

   [Enable the API](https://console.cloud.google.com/apis/enableflow?apiid=biglake.googleapis.com)
3. [Set up the Lakehouse runtime catalog](https://docs.cloud.google.com/lakehouse/docs/set-up-lakehouse-iceberg-rest-catalog.md.txt) with the Apache Iceberg REST catalog endpoint.
4. Review the [limitations of Iceberg
   views](https://docs.cloud.google.com/lakehouse/docs/manage-views#limitations).
5. [Create a view](https://docs.cloud.google.com/lakehouse/docs/create-view.md.txt).

### Required roles

Because your compute engine evaluates views client-side, you need permissions
on the view and on every table and nested view that the view references.


To get the permissions that
you need to query a view,

ask your administrator to grant you the
following IAM roles on your project and storage bucket:

- Read the view and referenced tables in [credential vending mode](https://docs.cloud.google.com/lakehouse/docs/credential-vending.md.txt): BigLake Viewer (`roles/biglake.viewer`) - your project
- Read the view and referenced tables in end-user credentials mode:
  - BigLake Viewer (`roles/biglake.viewer`) - your project
  - Storage Object Viewer (`roles/storage.objectViewer`) - the Cloud Storage bucket


For more information about granting roles, see [Manage access to projects, folders, and organizations](https://docs.cloud.google.com/iam/docs/granting-changing-revoking-access.md.txt).


These predefined roles contain

the permissions required to query a view. To see the exact permissions that are
required, expand the **Required permissions** section:


#### Required permissions

The following permissions are required to query a view:

- Query a view:
  - `biglake.views.get` on the view and any nested views
  - `biglake.tables.get` on each Iceberg table that the view references
- Read table data in credential vending mode: `biglake.tables.getData` on each Iceberg table that the view references
- Read view metadata and table data in end-user credentials mode: `storage.objects.get` on the Cloud Storage bucket


You might also be able to get
these permissions
with [custom roles](https://docs.cloud.google.com/iam/docs/creating-custom-roles.md.txt) or
other [predefined roles](https://docs.cloud.google.com/iam/docs/roles-overview.md.txt#predefined).

For a complete list of view permissions, see [Required roles and
permissions](https://docs.cloud.google.com/lakehouse/docs/manage-views#required_roles_and_permissions).

## Query a view

Select all data from a view:

### Spark

```sql
SELECT * FROM NAMESPACE_NAME.VIEW_NAME;
```

Replace the following:

- `NAMESPACE_NAME`: the name of your [namespace](https://docs.cloud.google.com/lakehouse/docs/set-up-lakehouse-iceberg-rest-catalog.md.txt#create_a_namespace_or_schema).
- `VIEW_NAME`: the name of your view.

You can query views that contain joins, aggregations, CTEs, and nested views in
the same way. For example, the following queries use the views from [Create a
view](https://docs.cloud.google.com/lakehouse/docs/create-view):

```sql
SELECT * FROM my_ns.eng_employees ORDER BY emp_id;
SELECT * FROM my_ns.employee_directory ORDER BY id;
SELECT * FROM my_ns.top_eng_employees;
```

## Time travel and views

You can't apply a time travel clause such as `TIMESTAMP AS OF` or
`VERSION AS OF` directly to a view identifier. If you need historical data,
define a view whose SQL definition applies time travel to the underlying table,
or use a CTE that queries the underlying table directly. For more information,
see [Create a view with time travel on underlying
tables](https://docs.cloud.google.com/lakehouse/docs/create-view#create_a_view_with_time_travel_on_underlying_tables).

## What's next

- Learn how to [get view details](https://docs.cloud.google.com/lakehouse/docs/get-view-details.md.txt).
- Learn how to [troubleshoot Iceberg views](https://docs.cloud.google.com/lakehouse/docs/troubleshoot-views.md.txt).