GoogleSQL for BigQuery supports the following ObjectRef functions.

This topic includes functions that let you create and interact with
[`ObjectRef`](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt) and
[`ObjectRefRuntime`](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/objectref_functions.md.txt#objectrefruntime)
values.

An `ObjectRef` value represents a Cloud Storage object, including the object
URI, size, type, and similar metadata. It also contains an authorizer, which
identifies the
[Cloud resource connection](https://docs.cloud.google.com/bigquery/docs/create-cloud-resource-connection.md.txt)
to use to access the Cloud Storage object from BigQuery. An `ObjectRef`
value is a `STRUCT` that has the following format:

```googlesql
STRUCT {
  uri string,  // Cloud Storage object URI
  version string,  // Cloud Storage object version
  authorizer string,  // Cloud resource connection to use for object access
  details json {  // Cloud Storage managed object metadata
    gcs_metadata json {
      "content_type": string,  // for example, "image/png"
      "md5_hash": string,  // for example, "d9c38814e44028bf7a012131941d5631"
      "size": number,  // for example, 23000
      "updated": number  // for example, 1741374857000000
    }
  }
}
```

The fields in the
`gcs_metadata` JSON refer to the [object metadata](https://docs.cloud.google.com/storage/docs/metadata.md.txt)
for a Cloud Storage object.

## Function list

| Name | Summary |
|---|---|
| [`OBJ.FETCH_METADATA`](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/objectref_functions.md.txt#objfetch_metadata) | Fetches Cloud Storage or Google Drive ([Preview](https://cloud.google.com/products#product-launch-stages)) metadata for a partially populated `ObjectRef` value. |
| [`OBJ.GET_ACCESS_URL`](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/objectref_functions.md.txt#objget_access_url) | Returns access URLs for a Cloud Storage object. |
| [`OBJ.GET_READ_URL`](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/objectref_functions.md.txt#objget_read_url) | Returns a read URL and status for a Cloud Storage object. |
| [`OBJ.LIST`](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/objectref_functions.md.txt#objlist) | Returns a table of metadata and `ObjectRef` values for files stored in Cloud Storage and Google Drive ([Preview](https://cloud.google.com/products#product-launch-stages)). |
| [`OBJ.MAKE_REF`](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/objectref_functions.md.txt#objmake_ref) | Creates an `ObjectRef` value that contains reference information for a Cloud Storage or Google Drive ([Preview](https://cloud.google.com/products#product-launch-stages)) object. |

## `OBJ.FETCH_METADATA`

```googlesql
OBJ.FETCH_METADATA(
  objectref
)
```

```googlesql
OBJ.FETCH_METADATA(
  ARRAY<objectref>
)
```

**Description**

To use this function with Google Drive, you must be added to the
allowlist. To request access for your project, send an email to
[bq-objectref-feedback@google.com](mailto:bq-objectref-feedback@google.com) with
your project ID.

The `OBJ.FETCH_METADATA` function returns Cloud Storage or Google Drive metadata
for a partially populated
[`ObjectRef` value](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt).

For Cloud Storage, this function lets the `ObjectRef` value use either
[direct access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#direct-access) or
[delegated access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#delegated-access) to the
object.

For Google Drive, this function uses end-user credentials.

This function still succeeds if there is a problem fetching metadata. In this
case, the `details` field contains an `error` field with the
error message, as shown in the following example:

    {
      "details": {
        "errors": [{
          "code":400,
          "message":"Connection credential for projects/myproject/locations/us/connections/connection1 cannot be used. Either the connection does not exist, or the user does not have sufficient permissions to use it.",
          "source":"OBJ.FETCH_METADATA",
        }]
      }
    }

**Definitions**

- `objectref`: A partially populated `ObjectRef` value, in which the `uri` field is populated, the `authorizer` field is optional (Cloud Storage only), and the `details` field is not populated.

**Output**

If your input is a single `ObjectRef` value, then the function returns
a fully populated `ObjectRef` value. The metadata is provided in the `details`
field of the returned `ObjectRef` value.

If your input is an array of `ObjectRef` values, then the function returns
an array of fully populated `ObjectRef` values. The metadata
is provided in the `details` field of each returned `ObjectRef` value.

**Examples**

The following query populates the metadata fields for an `ObjectRef` value
based on a PNG object in a publicly available Cloud Storage bucket:

```googlesql
SELECT
  OBJ.FETCH_METADATA(
    OBJ.MAKE_REF("gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/images/aquaclear-aquarium-background-poster.png", "us.connection1")
  ) AS obj;

/*---+---+---+---+
 | obj.uri                     | obj.version      | obj.authorizer           | obj.details                                      |
 +---+---+---+---+
 | gs://cloud-samples-data/... | 1742492679764550 | myproject.us.connection1 | {"gcs_metadata":                                 |
 |                             |                  |                          |   {"content_type":"image/png",                   |
 |                             |                  |                          |   "md5_hash":"e83227b9915e26bf7a42a38f7ce8d415", |
 |                             |                  |                          |   "size":1629498,                                |
 |                             |                  |                          |   "updated":1742492679000000                     |
 |                             |                  |                          |   }                                              |
 |                             |                  |                          | }                                                |
 +---+---+---+---*/
```

The following query populates the metadata fields for each `ObjectRef` value in
the input array. The result is a single row that contains an array of
`ObjectRef` values.

```googlesql
SELECT
  OBJ.FETCH_METADATA(
    [
      OBJ.MAKE_REF("gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/images/aquaclear-aquarium-background-poster.png", "us.connection1"),
      OBJ.MAKE_REF("gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/images/aquaclear-aquarium-fish-net.png", "us.connection1")
    ]
  ) AS obj;

/*---+---+---+---+
 | obj.uri                     | obj.version      | obj.authorizer           | obj.details                                      |
 +---+---+---+---+
 | gs://cloud-samples-data/... | 1742492679764550 | myproject.us.connection1 | {"gcs_metadata":                                 |
 |                             |                  |                          |   {"content_type":"image/png",                   |
 |                             |                  |                          |   "md5_hash":"e83227b9915e26bf7a42a38f7ce8d415", |
 |                             |                  |                          |   "size":1629498,                                |
 |                             |                  |                          |   "updated":1742492679000000                     |
 |                             |                  |                          |   }                                              |
 |                             |                  |                          | }                                                |
 | gs://cloud-samples-data/... | 1742492681709630 | myproject.us.connection1 | {"gcs_metadata":                                 |
 |                             |                  |                          |   {"content_type":"image/png",                   |
 |                             |                  |                          |   "md5_hash":"07715c290072a357a11fb89da940b3cf", |
 |                             |                  |                          |   "size":1163692,                                |
 |                             |                  |                          |   "updated":1742492681000000                     |
 |                             |                  |                          |   }                                              |
 |                             |                  |                          | }                                                |
 +---+---+---+---*/
```

The following query populates the metadata fields for an `ObjectRef` value
based on a Google Drive file:

```googlesql
SELECT
  OBJ.FETCH_METADATA(
    OBJ.MAKE_REF("https://drive.google.com/file/d/1A2b3C4d5E6f7G8h9I0j")
  ) AS object;
```

**Limitations**

You can't have more than 20 Cloud resource connections in the project and
region where your query accesses object data as `ObjectRef` values.

## `OBJ.GET_ACCESS_URL`

```googlesql
OBJ.GET_ACCESS_URL(
  objectref,
  mode
  [, duration]
)
```

```googlesql
OBJ.GET_ACCESS_URL(
  ARRAY<objectref>,
  mode
  [, duration]
)
```

**Description**

The `OBJ.GET_ACCESS_URL` function returns a JSON value that contains reference
information for the input
[`ObjectRef`](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt)
value, and also
access URLs that you can use to read or modify the Cloud Storage object.
This function isn't supported for Google Drive objects.

This function requires you to use
[delegated access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#delegated-access)
to read the object.

If the function encounters an error, the returned JSON contains a
`errors` field with the error message instead of the
`access_urls` field with the access URLs. The following example shows an
error message:

    {
      "objectref": {
        "authorizer": "myproject.us.connection1",
        "uri": "gs://mybucket/path/to/file.jpg"
      },
      "errors": [{
        "code":400,
        "message":"Connection credential for projects/myproject/locations/us/connections/connection1 cannot be used. Either the connection does not exist, or the user does not have sufficient permissions to use it.",
        "source":"OBJ.GET_ACCESS_URL",
      }]
    }

**Definitions**

- `objectref`: An `ObjectRef` value that represents a Cloud Storage object.
- `mode`: A `STRING` value that identifies the type of URL that you want to
  be returned. The following values are supported:

  - `r`: Returns a URL that lets you read the object.
  - `rw`: Returns two URLs, one that lets you read the object, and one that lets you modify the object.
- `duration`: An optional [`INTERVAL`](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/data-types.md.txt#interval_type) value that specifies how long
  the generated access URLs remain valid. You can specify a value between
  30 minutes and 6 hours. For example, you could specify
  `INTERVAL 2 HOUR` to generate URLs that expire after 2 hours. The default
  value is 6 hours.

**Output**

A JSON value or array of JSON values that contains the Cloud Storage object
reference
information from the input `ObjectRef` value, and also one or more URLs that
you can use to access the Cloud Storage object.

The JSON output is returned in the `ObjectRefRuntime`
schema:

    obj_ref_runtime json {
      obj_ref json {
        uri string, // Cloud Storage object URI
        version string, // Cloud Storage object version
        authorizer string, // Cloud resource connection to use for object access
        details json { // Cloud Storage managed object metadata
          gcs_metadata json {
          }
        }
      }
      access_urls json {
        read_url string, // read-only signed url
        write_url string, // writeable signed url
        expiry_time string // the URL expiration time in YYYY-MM-DD'T'HH:MM:SS'Z' format
      }
    }

**Example**

This example returns read URLs for all of the image objects associated with
the films in the `mydataset.films` table, where the `poster` column is a
struct in the `ObjectRef` schema. The URLs expire in 45 minutes.

```googlesql
SELECT
  OBJ.GET_ACCESS_URL(poster, 'r', INTERVAL 45 MINUTE) AS read_url
FROM mydataset.films;
```

**Limitations**

- The `OBJ.GET_ACCESS_URL` function isn't supported for projects with [VPC Service Controls](https://docs.cloud.google.com/bigquery/docs/vpc-sc.md.txt) enabled. BigQuery blocks calls to this function at query planning time even when the Cloud Storage bucket is in the same project or perimeter, or when you don't specify a connection. There's no SQL workaround to generate signed URLs. To pass Cloud Storage objects to AI functions inside a perimeter, pass an `ObjectRef` value without a connection (such as `OBJ.MAKE_REF(uri)`) for [direct access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#direct-access) instead. Direct access requires that you have read permission on the objects and AI function permissions, and that the Cloud Storage buckets are in the same project.
- You can't have more than 20 Cloud resource connections in the project and region where your query accesses object data as `ObjectRef` values.

## `OBJ.GET_READ_URL`

```googlesql
OBJ.GET_READ_URL(objectref)
```

**Description**

The `OBJ.GET_READ_URL` function returns a `STRUCT` value that contains a read
URL that you can use to read the Cloud Storage object. The URL expires after
45 minutes. This function isn't supported for Google Drive objects.

This function requires you to use
[delegated access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#delegated-access) to read
for the input `ObjectRef` value.

**Definitions**

- `objectref`: an `ObjectRef` value that represents a Cloud Storage object

**Output**

A `STRUCT` value that contains the following fields:

- `url`: a read URL that you can use to read the Cloud Storage object. If the function can't create the read URL, then this value is `NULL`.
- `status`: an error message. If the function successfully creates the read URL, then this value is `NULL`.

**Examples**

In the following example, the `mydataset.films` table has a
`STRUCT` column `poster` that contains values with the `ObjectRef` schema.
The following query returns a read URL for each of the image objects associated
with the films:

```googlesql
SELECT
  OBJ.GET_READ_URL(poster) AS read_url
FROM mydataset.films;

/*---+---+
 | read_url.url                                                   | read_url.status |
 +---+---+
 | https://storage.googleapis.com/posters/poster-1.jpg?X-Goog-... | NULL            |
 +---+---*/
```

When you run this query in Studio, the `read_url.url` column
displays the images corresponding to the read URLs. To view the text of the
URLs, select the **JSON** tab in the **Query results** pane.

**Limitations**

- The `OBJ.GET_READ_URL` function isn't supported for projects with [VPC Service Controls](https://docs.cloud.google.com/bigquery/docs/vpc-sc.md.txt) enabled. BigQuery blocks calls to this function at query planning time even when the Cloud Storage bucket is in the same project or perimeter, or when you don't specify a connection. There's no SQL workaround to generate signed URLs. To pass Cloud Storage objects to AI functions inside a perimeter, pass an `ObjectRef` value without a connection (such as `OBJ.MAKE_REF(uri)`) for [direct access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#direct-access) instead. Direct access requires that you have read permission on the objects and AI function permissions, and that the Cloud Storage buckets are in the same project.
- You can't have more than 20 connections in the project and region in which your query accesses object data as `ObjectRef` values.

## `OBJ.LIST`

```googlesql
OBJ.LIST(
  uri
  [, authorizer ]
)
```

**Description**

To use this function with Google Drive, you must be added to the
allowlist. To request access for your project, send an email to
[bq-objectref-feedback@google.com](mailto:bq-objectref-feedback@google.com) with
your project ID.

The `OBJ.LIST` function returns a table of metadata and `ObjectRef` values for
files stored in Cloud Storage and Google Drive ([Preview](https://docs.cloud.google.com/products#product-launch-stages)). `OBJ.LIST`
lets you perform ad hoc discovery and analysis of unstructured data.

The Cloud Storage data can include documents,
images, and audio. The `OBJ.LIST` function can discover objects across all
[Cloud Storage classes](https://docs.cloud.google.com/storage/docs/storage-classes.md.txt).

Using `OBJ.LIST` replaces the need to manually construct `ObjectRef` values.
You can quickly add Cloud Storage and Google Drive objects into AI functions to
build ETL pipelines that handle converting unstructured data to structured
data. If you require a persistent, self-updating table that continuously tracks
new objects that arrive in a bucket over time, you should create a standard
[BigQuery object table](https://docs.cloud.google.com/bigquery/docs/object-table-introduction.md.txt)
instead. Persistent object tables aren't supported for Google Drive.

For more information, see [Work with `ObjectRef` values](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt).

**Definitions**

- `uri`: a `STRING` value that contains the URI for the Cloud Storage or
  Google Drive object, for example, `gs://mybucket/flowers/12345.jpg` or
  `https://drive.google.com/file/d/{file_id}`. Scalar subqueries and string
  manipulation functions such as `CONCAT` aren't supported. For Cloud Storage,
  URIs that end in a slash or URIs that contain consecutive slashes aren't
  supported.

  For Cloud Storage, you can use one asterisk (`*`) wildcard
  character in each path to limit the objects included in the results. For
  example, if the bucket contains several types of unstructured data, you
  can list only PDF objects by specifying `gs://bucket_name/*.pdf`. For more
  information, see [Wildcard support for Cloud Storage
  URIs](https://docs.cloud.google.com/bigquery/docs/external-data-cloud-storage#wildcard-support). If you append a wildcard path, such as `/*`, to a
  Google Drive folder URI, the wildcard and any preceding slash are silently
  ignored and all items in the folder are returned. Appending `*` directly to
  the folder ID without a slash returns an invalid URI error. To filter Google
  Drive files, use a `WHERE` SQL clause instead. To learn more, see
  [Use the `OBJ.LIST` function with Google Drive](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#obj-list-drive).

  You can't mix Cloud Storage and Google Drive URIs in a single `OBJ.LIST`
  call. To query both, use `UNION ALL` with separate `OBJ.LIST` calls.
- `authorizer`: an optional `STRING` value that contains the
  [Cloud Resource connection](https://docs.cloud.google.com/bigquery/docs/create-cloud-resource-connection.md.txt)
  used for [delegated access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#delegated-access)
  to the Cloud Storage object. Your data administrator needs to set up the
  permissions to use this connection. If omitted, the returned ObjectRef uses
  [direct access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#direct-access).

  > [!NOTE]
  > **Note:** The `authorizer` argument is only supported for Cloud Storage. Queries against Google Drive use end-user credentials.

**Output**

A table with metadata that represents the objects found in
Cloud Storage or Google Drive. The table includes the following columns:

- `uri`: a `STRING` value that contains the URI of the object. For Google Drive, this is always normalized to `https://drive.google.com/open?id={file_id}` regardless of the input format, and the file name isn't included in the URI.
- `content_type`: a `STRING` value that contains the MIME type of the object, for example, `image/jpeg` or `application/pdf`.
- `size`: an `INT64` value that contains the object size in bytes. For Google Drive, this is `-1` for Google Workspace files (such as Docs, Sheets, and Slides), folders, shortcuts, and empty files.
- `md5_hash`: a `STRING` value that contains the MD5 hash of the object. For Google Drive, this is always `NULL`.
- `updated`: a `TIMESTAMP` value that contains the time the object was last updated.
- `metadata`: an `ARRAY<STRUCT<name STRING, value STRING>>` value that contains additional Cloud Storage metadata.
- `generation`: an `INT64` value that identifies the [version of an
  object](https://docs.cloud.google.com/storage/docs/metadata#generation-number), and exists for every Cloud Storage object, regardless of whether a bucket uses object versioning. For Google Drive, this is always `-1`.
- `ref`: an `ObjectRef` value that represents the Cloud Storage or Google Drive object. This value can be passed to other `OBJ` and `AI` functions.

> [!NOTE]
> **Note:** When you use `OBJ.LIST` with Google Drive, it returns subfolders and shortcuts, which must be filtered out before passing `ref` to `AI.*` functions.

**Examples**

The examples demonstrate how to use `OBJ.LIST` to perform spontaneous analysis
of unstructured data. These examples omit the `authorizer` argument, which means
that the queries use [direct access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#direct-access).
If your environment requires [delegated access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#delegated-access) for Cloud
Storage, add the `authorizer` argument to the query.

The following query uses the wildcard character (\*) to discover specific file
types in Cloud Storage, and it uses the `AI.IF` function to filter unstructured
data. This query lists PNG files that contain an image of a dog.

```googlesql
SELECT
  uri,
  content_type,
  size
FROM
  OBJ.LIST('gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/images/*.png')
WHERE
  AI.IF(('Does this image contain a dog?', ref))
ORDER BY
  uri;

/*---+---+---+
 | uri                                                            | content_type | size   |
 +---+---+---+
 | gs://.../k9-guard-dog-ear-cleaner.png                          | image/png    | 584558 |
 | gs://.../k9-guard-dog-paw-wipes.png                            | image/png    | 785219 |
 | gs://.../k9-guard-dog-toothpaste.png                           | image/png    | 732191 |
 | gs://.../k9-guard-flea-&-tick-shampoo.png                      | image/png    | 1144191|
 | gs://.../playful-pup-dog-training-book.png                     | image/png    | 1106425|
 | gs://.../playful-pup-dog-training-clicker-with-training-dvd.png| image/png    | 1203398|
 +---+---+---*/
```

The following example shows how to list all files in a Google Drive folder
and filter them by MIME type or file name:

```googlesql
-- Option A: Filter by MIME type
SELECT
  uri,
  JSON_VALUE(ref.details, '$.gdrive_metadata.file_name') AS file_name,
  content_type,
  size
FROM
  OBJ.LIST('https://drive.google.com/drive/folders/1A2b3C4d5E6f7G8h9I0j')
WHERE
  content_type = 'application/pdf'
ORDER BY
  file_name;

-- Option B: Filter by file name pattern in ref.details
SELECT
  uri,
  JSON_VALUE(ref.details, '$.gdrive_metadata.file_name') AS file_name,
  content_type,
  size
FROM
  OBJ.LIST('https://drive.google.com/drive/folders/1A2b3C4d5E6f7G8h9I0j')
WHERE
  JSON_VALUE(ref.details, '$.gdrive_metadata.file_name') LIKE '%.pdf'
ORDER BY
  file_name;
```

The following example combines the `OBJ.LIST` and `AI.GENERATE` functions with
the `output_schema` parameter to build an unstructured-to-structured data
pipeline using a single query. This example reads raw images and extracts
strictly typed properties into standard BigQuery columns without
creating a persistent object table.

```googlesql
SELECT
  uri,
  result.animal_type,
  result.item_color
FROM (
  SELECT
    uri,
    AI.GENERATE(
      ("What type of animal is this pet product for, and what is its primary color?", ref),
      output_schema => 'animal_type STRING, item_color STRING'
    ) AS result
  FROM
    OBJ.LIST('gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/images/*.png')
);

/*---+---+---+
 | uri                                                                      | animal_type | item_color |
 +---=---+---+---+
 | gs://cloud-samples-data/.../aquaclear-aquarium-filter-media-bag.png      | fish        | white      |
 | gs://cloud-samples-data/.../cozy-naps-cat-scratching-pad-with-catnip.png | cat         | brown      |
 | gs://cloud-samples-data/.../cozy-naps-cat-teaser-wand.png                | cat         | white      |
 | gs://cloud-samples-data/.../fluffy-buns-chinchilla-play-tunnel.png       | cat         | blue       |
 | gs://cloud-samples-data/.../fluffy-buns-rabbit-hay.png                   | rabbit      | green      |
 | gs://cloud-samples-data/.../k9-guard-dog-muzzle.png                      | dog         | black      |
 | ...                                                                      |             |            |
 +---+---+---*/
```

The following example uses the `AI.IF` function to review a directory of
unstructured files for policy violations based on their semantic, visual, or
audio content. This query reviews a folder of product manuals and returns only
the files that are missing crucial safety warnings.

```googlesql
SELECT
  uri
FROM
  OBJ.LIST('gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/documents/*')
WHERE
  AI.IF(('Determine if this product manual is missing standard choking hazard safety warnings.', ref))
ORDER BY
  uri;

/*---+
 | uri                                                                         |
 +---+
 | gs://cloud-samples-data/.../documents/crittercuisine_5000_user_manual.pdf   |
 +---*/
```

The following example uses the `OBJ.LIST` function to aggregate references into
arrays to pass multiple files to simultaneously. This
query retrieves three product images, and asks to
synthesize the visual theme of the files.

```googlesql
WITH product_images AS (
  SELECT ref
  FROM OBJ.LIST('gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/images/*.png')
  LIMIT 3
)
SELECT
  AI.GENERATE(
    ('What are the common visual themes or branding elements across these pet products?', ARRAY_AGG(ref))
  ).result AS comparison_summary
FROM
  product_images;

/*---+
 | comparison_summary                                                          |
 +---+
 | Based on the provided images, the common visual themes or branding elements |
 | across these pet products, which appear to be related to aquariums and      |
 | aquarium accessories, are:                                                  |
 | 1.  **Clean and Minimalist Aesthetics**                                     |
 |     ...                                                                     |
 | 2.  **Focus on Clarity and Transparency (for aquariums)**                   |
 |     ...                                                                     |
 | 3.  **Modern and Neutral Color Palette**                                    |
 |     ...                                                                     |
 | 4.  **Subtle Branding (where visible)**                                     |
 |     ...                                                                     |
 | 5.  **Quality and Durability (implied)**                                    |
 |     ...                                                                     |
 +---*/
```

**Limitations**

The following object table limitations apply to the `OBJ.LIST` function. Because
`OBJ.LIST` dynamically generates object metadata, it shares many of the same
underlying behaviors and limitations as [object tables](https://docs.cloud.google.com/bigquery/docs/object-table-introduction.md.txt).

- **Cloud Storage constraints**:

  - If you use a BigQuery connection, the connection's location and the query location must be compatible with the Cloud Storage bucket's region.
  - Access to Cloud Storage data is governed by your organization's [VPC Service Controls perimeters](https://docs.cloud.google.com/vpc-service-controls/docs/service-perimeters.md.txt).
- **Google Drive constraints** : see [Limitations](https://docs.cloud.google.com/bigquery/docs/analyze-multimodal-data.md.txt#limitations).

## `OBJ.MAKE_REF`

This function supports the following syntaxes:

```googlesql
OBJ.MAKE_REF(
  uri
  [, authorizer ]
  [, version => version_value ]
  [, details => { gcs_metadata | gdrive_metadata } ]
)
```

```googlesql
OBJ.MAKE_REF(
  objectref
)
```

When you use this syntax, the top-level `authorizer` argument overwrites
any `authorizer` that you specify in the `objectref` argument.

```googlesql
OBJ.MAKE_REF(
  objectref,
  authorizer
)
```

**Description**

To use this function with Google Drive, you must be added to the
allowlist. To request access for your project, send an email to
[bq-objectref-feedback@google.com](mailto:bq-objectref-feedback@google.com) with
your project ID.

Use the `OBJ.MAKE_REF` function to create an
[`ObjectRef` value](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt)
that contains reference information for a Cloud Storage or Google Drive
([Preview](https://docs.cloud.google.com/products#product-launch-stages)) object.
You can use this function in workflows similar to the following:

1. Transform an object.
2. Save it to Cloud Storage using a writable signed URL that you created by using the [`OBJ.GET_ACCESS_URL` function](https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/objectref_functions.md.txt#objget_access_url).
3. Create an `ObjectRef` value for the transformation output by using the `OBJ.MAKE_REF` function.
4. Save the `ObjectRef` value by writing it to a table column.

**Definitions**

- `uri`: a `STRING` value that contains the URI for the Cloud Storage or Google Drive object, for example, `gs://mybucket/flowers/12345.jpg` or `https://drive.google.com/file/d/{file_id}`. You can also specify a column name in place of a string literal. For example, if you have URI data in a `uri` field, you can specify `OBJ.MAKE_REF(uri, "myproject.us.conn")`.
- `authorizer`: an optional `STRING` value that contains the
  [Cloud Resource connection](https://docs.cloud.google.com/bigquery/docs/create-cloud-resource-connection.md.txt)
  used for [delegated access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#delegated-access)
  to the Cloud Storage object. Your data
  administrator needs to set up the permissions to use this connection. If
  omitted, the returned ObjectRef uses
  [direct access](https://docs.cloud.google.com/bigquery/docs/work-with-objectref.md.txt#direct-access).

  > [!NOTE]
  > **Note:** The `authorizer` argument is only supported for Cloud Storage. Queries against Google Drive use end-user credentials.

- `version_value`: a `STRING` value that represents the Cloud Storage object
  version. This argument isn't supported for Google Drive objects.

- `gcs_metadata` or `gdrive_metadata`: a `JSON` value that represents Cloud
  Storage or Google Drive metadata,
  using one of the following schemas:

      "gcs_metadata": {
        "content_type": string,
        "md5_hash": string,
        "size": number,
        "updated": number
      }

      "gdrive_metadata": {
        "file_name": string,
        "content_type": string,
        "size": number,
        "updated": number
      }

- `objectref`: a `JSON` value that represents a Cloud Storage or Google
  Drive object, using the following schema (`authorizer` and `version` are
  supported only for Cloud Storage):

      objectref {
        uri string,
        [, authorizer string ]
        [, version string]
        [, details { gcs_metadata | gdrive_metadata } ]
      }

Validation is performed on the formatting of the input, but not the content.

**Output**

An `ObjectRef` value.

- If you provide a URI as input, then the output is a reference to the Cloud Storage or Google Drive object identified by the URI.
- If you provide an ObjectRef JSON value, then the output contains all of the input information formatted as an ObjectRef value.
- If you provide an ObjectRef value and authorizer, then the output contains the input ObjectRef value with an updated authorizer.

**Examples**

The following example creates an `ObjectRef` value using a URI and a Cloud
resource connection as input:

```googlesql
CREATE OR REPLACE TABLE `mydataset.movies` AS (
  SELECT
    f.title,
    f.director
    OBJ.MAKE_REF(p.uri, 'asia-south2.storage_connection') AS movie_poster
  FROM mydataset.movie_posters p
  join mydataset.films f
  using(title)
  where region = 'US'
  and release_year = 2024
);
```

The following example creates an `ObjectRef` value using JSON input:

```googlesql
OBJ.MAKE_REF(JSON '{"uri": "gs://cloud-samples-data/bigquery/tutorials/cymbal-pets/images/aquaclear-aquarium-background-poster.png", "authorizer": "asia-south2.storage_connection"}');
```

The following example creates a new `ObjectRef` value with an updated
authorizer:

```googlesql
SELECT
  OBJ.MAKE_REF(movie_poster,
               authorizer=>'asia-south2.new_connection') AS movie_poster_updated
FROM mydataset.movies
```

The following example creates an `ObjectRef` value using a Google Drive URI:

```googlesql
SELECT
  OBJ.MAKE_REF("https://drive.google.com/file/d/1A2b3C4d5E6f7G8h9I0j")
   AS object;
```

**Limitations**

You can't have more than 20 Cloud resource connections in the project and
region where your query accesses object data as `ObjectRef` values. Connections
are only applicable to Cloud Storage objects.