prestodb/presto · error · PrestoException

BIGQUERY_FAILED_TO_EXECUTE_QUERY

BIGQUERY_FAILED_TO_EXECUTE_QUERY

Error message

Failed to compute empty projection

What it means

BigQuerySplitManager.createEmptyProjection builds splits for queries with no columns (e.g. SELECT count(*)) by generating empty-projection splits; any BigQueryException during that computation is rethrown as BIGQUERY_FAILED_TO_EXECUTE_QUERY with this message. It means the connector failed while planning/sizing the empty-projection splits.

Source

Thrown at presto-bigquery/src/main/java/com/facebook/presto/plugin/bigquery/BigQuerySplitManager.java:133

                String sql = bigQueryClient.createFormatSql(tableId, "COUNT(*)", new String[] {filter.get()});
                TableResult result = bigQueryClient.query(sql);
                numberOfRows = result.iterateAll().iterator().next().get(0).getLongValue();
            }
            else {
                // no filters, so we can take the value from the table info
                numberOfRows = bigQueryClient.getTable(tableId).getNumRows().longValue();
            }

            long rowsPerSplit = numberOfRows / actualParallelism;
            long remainingRows = numberOfRows - (rowsPerSplit * actualParallelism); // need to be added to one of the split due to integer division
            List<BigQuerySplit> splits = range(0, actualParallelism)
                    .mapToObj(ignored -> BigQuerySplit.emptyProjection(rowsPerSplit))
                    .collect(toList());
            splits.set(0, BigQuerySplit.emptyProjection(rowsPerSplit + remainingRows));
            return splits;
        }
        catch (BigQueryException e) {
            throw new PrestoException(BIGQUERY_FAILED_TO_EXECUTE_QUERY, "Failed to compute empty projection", e);
        }
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Look at the wrapped BigQueryException cause for the root reason and address it (permissions, quota, table existence)
  2. Verify the table still exists and the service account has access
  3. Retry the query if the cause was transient
  4. Check BigQuery API quotas and error details in Google Cloud logs
Defensive patterns

Strategy: try-catch

Validate before calling

// before empty-projection queries, verify table access
Table table = bigQueryClient.getTable(tableId);
if (table == null) {
    throw new IllegalStateException("Table not found or not accessible: " + tableId);
}

Try / catch

try {
    return splitManager.getSplits(...);
} catch (PrestoException e) {
    if (BIGQUERY_FAILED_TO_EXECUTE_QUERY.getCode() == e.getErrorCode().getCode()) {
        log.error("Empty projection failed; cause: %s", e.getCause());
        // address cause (permissions/quota/table existence) then retry
    }
    throw e;
}

Prevention

When it happens

Trigger: Running a query with an empty projection (e.g. SELECT COUNT(*) FROM table) when the split computation against BigQuery metadata throws a BigQueryException (API errors, missing table, quota).

Common situations: Table dropped/renamed between metadata fetch and split computation; BigQuery API quota/rate limits; permission revocations; transient API outages.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/ceab0f266aa5d3af. Report an issue: GitHub.