async function grantAccessToDataset() {
    const [dataset] = await client.dataset(datasetId).get();

    // The 'access entries' array is immutable. Create a copy for modifications.
    const entries = [...dataset.metadata.access];

    // Append an AccessEntry to grant the role to a dataset.
    // Find more details about the AccessEntry object in the BigQuery documentation:
    // https://cloud.google.com/python/docs/reference/bigquery/latest/google.cloud.bigquery.dataset.AccessEntry
    entries.push({
      role,
      [entityType]: entityId,
    });

    // Assign the array of AccessEntries back to the dataset.
    const metadata = {
      access: entries,
    };

    // Update will only succeed if the dataset
    // has not been modified externally since retrieval.
    //
    // See the BigQuery client library documentation for more details on metadata updates:
    // https://cloud.google.com/nodejs/docs/reference/bigquery/latest

    // Update just the 'access entries' property of the dataset.
    await client.dataset(datasetId).setMetadata(metadata);

    console.log(
      `Role '${role}' granted for entity '${entityId}' in '${datasetId}'.`
    );
  }
TODO(developer): Update and un-comment below lines.