The Lakehouse runtime catalog lets you alter Apache Iceberg tables to
evolve schemas, such as adding columns, and configure table properties. These
updates help you store custom metadata or opt in to BigQuery-managed
capabilities (Preview), including BigQuery Data Manipulation
Language (DML) and automatic table maintenance.

You can alter tables using the Google Cloud console, Apache Spark,
Trino, BigQuery (Preview), or the REST API. To update table
properties from the command line, you can also use the Google Cloud CLI.

## Before you begin

1.
   Verify that
   [billing is enabled](https://docs.cloud.google.com/billing/docs/how-to/verify-billing-enabled.md.txt#confirm_billing_is_enabled_on_a_project) for your Google Cloud 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.

### Required roles


To get the permissions that
you need to alter a table,

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

- Alter table in [credential vending mode](https://docs.cloud.google.com/lakehouse/docs/credential-vending.md.txt): BigLake Editor (`roles/biglake.editor`) - the project
- Alter table in non-credential vending mode:
  - BigLake Editor (`roles/biglake.editor`) - the project
  - Storage Object User (`roles/storage.objectUser`) - 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).


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

## Table capabilities and support

When using tables in the Lakehouse runtime catalog, it's helpful to [understand
the different table types and their opt-in
capabilities](https://docs.cloud.google.com/lakehouse/docs/lakehouse-tables). To learn more about using
Apache Iceberg tables, see [Overview of Apache Iceberg
tables](https://docs.cloud.google.com/lakehouse/docs/manage-tables).

### Supported Iceberg tables

Only Apache Iceberg V2 (GA) and V3 (Preview) tables are supported. Iceberg V1
tables aren't supported. To upgrade existing V1 tables, see [Upgrade Iceberg V1
tables to V2](https://docs.cloud.google.com/lakehouse/docs/update-tables).

### Use table options (Preview)

You can opt in to use BigQuery-managed capabilities, such as
BigQuery Data Manipulation Language (DML) and automatic table
management, by configuring specific table properties. These features are enabled
in different ways depending on where the table is created:

- **From BigQuery:** BigQuery DML and automatic table management are enabled by default.
- **From open source engines:** To opt in, you must explicitly configure table properties. For more information, see [Configure table
  options](https://docs.cloud.google.com/lakehouse/docs/table-options).

See [Configure table
options](https://docs.cloud.google.com/lakehouse/docs/table-options) for detailed instructions.

## Alter a table

Select one of the following options:

### Console

1. In the Google Cloud console, go to the **Lakehouse** page.


   [Go to Lakehouse](https://console.cloud.google.com/biglake)

   <br />

2. Select an existing catalog, or create one if you don't have one.

3. Select an existing namespace, or create one if you don't have one.

4. On the **Namespace details** page, on the **Tables** tab, click the name
   of the table that you want to alter. The **Table details** page opens.

5. To add columns to the table schema, do the following:

   1. Click the **Schema** tab.
   2. Click **Edit schema**.
   3. In the **New fields** section, click **Add field** . In **Field
      name** , enter a column name, and in the **Type** list, select a data type. To enter fields as text instead, click the **Edit as
      text** toggle to the on position, and then enter JSON or comma-separated `name:type` pairs.
   4. Click **Save**.
6. To update table properties, do the following:

   1. Click the **Details** tab.
   2. Click **Edit details**.
   3. In the **Properties** section, update existing property values. To
      add a custom property, click **Add property** , and then in the
      **Key** and **Value** fields, enter the property key and value.

      For example, to enable BigQuery DML or automatic
      table maintenance, in the **Value** field for
      `gcp.biglake.bigquery-dml.enabled` or
      `gcp.biglake.table-management.enabled`, enter `true`. For more
      information, see
      [Configure table options](https://docs.cloud.google.com/lakehouse/docs/table-options.md.txt).
   4. Click **Update**.

### Spark

    spark.sql("ALTER TABLE TABLE_NAME ADD COLUMNS ( desc string);")
    spark.sql("DESCRIBE NAMESPACE_NAME.TABLE_NAME").show()

To enable [read/write interoperability and table maintenance](https://docs.cloud.google.com/lakehouse/docs/table-options.md.txt), set the properties using the `SET TBLPROPERTIES` clause:

```sql
SET TBLPROPERTIES (
  'gcp.biglake.bigquery-dml.enabled' = true,
  'gcp.biglake.table-management.enabled' = true
)
```

### Trino

    ALTER TABLE TABLE_NAME ADD COLUMN desc varchar;
    DESCRIBE SCHEMA_NAME.TABLE_NAME;

To enable [read/write interoperability and table maintenance](https://docs.cloud.google.com/lakehouse/docs/table-options.md.txt), you can configure the following table properties:

- `'gcp.biglake.bigquery-dml.enabled' = true`
- `'gcp.biglake.table-management.enabled' = true`

### gcloud

To update table properties using `gcloud`, run the
[`gcloud biglake iceberg tables update` command](https://docs.cloud.google.com/sdk/gcloud/reference/biglake/iceberg/tables/update).

```bash
gcloud biglake iceberg tables update TABLE_NAME \
    --project="PROJECT_ID" \
    --catalog="CATALOG_ID" \
    --namespace="NAMESPACE_NAME" \
    --update-properties="KEY=VALUE,..."
```

Replace the following:

- `TABLE_NAME`: the name of your Iceberg table.
- `PROJECT_ID`: your Google Cloud project ID.
- `CATALOG_ID`: the ID of your catalog.
- `NAMESPACE_NAME`: the name of your catalog namespace.
- `KEY=VALUE,...`: table properties to add or update.

### BigQuery


> [!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).

<br />

To update table properties for an Apache Iceberg table in the
Lakehouse runtime catalog from BigQuery (such
as enabling BigQuery DML or automatic table maintenance),
use the following GoogleSQL `ALTER TABLE`
statement:

```sql
ALTER TABLE `PROJECT_ID.CATALOG_ID.NAMESPACE.TABLE_NAME`
SET OPTIONS (`properties.gcp.biglake.table-management` = "enabled");
```

To update the schema and add a column in an Apache Iceberg table in the
Lakehouse runtime catalog from BigQuery,
use the following GoogleSQL `ALTER TABLE` statement:

```sql
ALTER TABLE `PROJECT_ID.CATALOG_ID.NAMESPACE.TABLE_NAME`
ADD COLUMN new_column STRING;
```

Replace the following:

- `PROJECT_ID`: your Google Cloud project ID.
- `CATALOG_ID`: the ID of your Lakehouse runtime catalog.
- `NAMESPACE`: your Iceberg namespace name.
- `TABLE_NAME`: the name of your Iceberg table.

### REST

To commit changes to an Iceberg table using the REST API, make a `POST`
request to the [`UpdateIcebergTable`](https://docs.cloud.google.com/lakehouse/docs/reference/rest/v1/iceberg.v1.restcatalog.v1.projects.catalogs.namespaces.tables/updateIcebergTable.md.txt) (`CommitTable`) endpoint:

```restructuredtext
POST /iceberg/v1/restcatalog/v1/projects/PROJECT_ID/catalogs/CATALOG_ID/namespaces/NAMESPACE_NAME/tables/TABLE_NAME
```

The request body must contain a valid Iceberg `CommitTableRequest` JSON
payload defining the base requirement and the list of metadata updates to
apply.

Replace the following:

- `PROJECT_ID`: your Google Cloud project ID.
- `CATALOG_ID`: the ID of your catalog.
- `NAMESPACE_NAME`: the name of your catalog namespace.
- `TABLE_NAME`: the name of your Iceberg table.

## What's next

- Learn how to [delete a table](https://docs.cloud.google.com/lakehouse/docs/delete-table.md.txt).