prestodb/presto · error · PrestoException
BIGQUERY_VIEW_DESTINATION_TABLE_CREATION_FAILED
BIGQUERY_VIEW_DESTINATION_TABLE_CREATION_FAILED
Error message
Error creating destination table
What it means
When views are enabled, getActualTable materializes a view via a DestinationTableBuilder cached by query SQL (destinationTableCache.get); an ExecutionException from that cache load is wrapped as BIGQUERY_VIEW_DESTINATION_TABLE_CREATION_FAILED. It means the background job that runs the view query and creates the destination table in BigQuery failed.
Source
Thrown at presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/ReadSessionCreator.java:124
{
TableDefinition tableDefinition = table.getDefinition();
TableDefinition.Type tableType = tableDefinition.getType();
if (TableDefinition.Type.TABLE == tableType) {
return table;
}
if (TableDefinition.Type.VIEW == tableType) {
if (!config.viewsEnabled) {
throw new PrestoException(NOT_SUPPORTED,
"Views are not enabled. You can enable views by setting 'bigquery.views-enabled' to true. Notice additional cost may occur.");
}
// get it from the view
String querySql = bigQueryClient.createSql(table.getTableId(), requiredColumns);
log.debug("querySql is %s", querySql);
try {
return destinationTableCache.get(querySql, new DestinationTableBuilder(bigQueryClient, config, querySql, table.getTableId()));
}
catch (ExecutionException e) {
throw new PrestoException(BigQueryErrorCode.BIGQUERY_VIEW_DESTINATION_TABLE_CREATION_FAILED, "Error creating destination table", e);
}
}
else {
// not regular table or a view
throw new PrestoException(NOT_SUPPORTED, format("Table type '%s' of table '%s.%s' is not supported",
tableType, table.getTableId().getDataset(), table.getTableId().getTable()));
}
}
static class DestinationTableBuilder
implements Callable<TableInfo>
{
final BigQueryClient bigQueryClient;
final ReadSessionCreatorConfig config;
final String querySql;
final TableId table;
DestinationTableBuilder(BigQueryClient bigQueryClient, ReadSessionCreatorConfig config, String querySql, TableId table)View on GitHub (pinned to 55bb57d202)
Solutions
- Inspect the ExecutionException cause for the BigQuery job error and fix the underlying issue
- Grant the service account permission to run queries and create tables in the destination dataset/project
- Verify the view itself executes in the BigQuery console
- Check quotas and the configured destination dataset for view materialization
Defensive patterns
Strategy: validation
Validate before calling
// preflight permissions for view materialization before querying
Policy bindings = iam.getPolicy(projectId);
boolean canCreateTables = serviceAccountHasRoles(bindings,
Set.of("roles/bigquery.dataEditor", "roles/bigquery.jobUser"));
if (!canCreateTables) {
throw new IllegalStateException("Service account cannot create destination tables");
} Try / catch
try {
return query.execute();
} catch (PrestoException e) {
if (BIGQUERY_VIEW_DESTINATION_TABLE_CREATION_FAILED.getCode() == e.getErrorCode().getCode()) {
Throwable root = e.getCause();
while (root.getCause() != null) root = root.getCause();
log.error("Destination table creation failed: %s", root.getMessage());
// fix permissions/SQL per root cause, then retry
}
throw e;
} Prevention
- Grant the service account bigquery.jobs.create and dataset write access
- Verify the view runs successfully in the BigQuery console first
- Set a sane view destination dataset and expiration in catalog config
- Unwrap and monitor the ExecutionException cause for quota/job errors
When it happens
Trigger: Querying an enabled view whose DestinationTableBuilder call fails — invalid view SQL, insufficient permissions to create tables in the dataset, BigQuery job errors, or quota limits.
Common situations: Service account lacking BigQuery jobs.create / dataset write permissions; the view's SQL referencing tables the service account cannot read; quota exceeded; destination dataset misconfigured (bigquery.view-expiration / project settings).
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/19e2d59d1b4c7d3d.
Report an issue: GitHub.