{"record":{"id":"37405316a54e6c9c","repo":"apache/seatunnel","slug":"failed-to-create-bigquery-dataset","errorCode":null,"errorMessage":"Failed to create BigQuery dataset: ","messagePattern":"Failed to create BigQuery dataset: ","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-bigquery/src/main/java/org/apache/seatunnel/connectors/bigquery/catalog/BigQueryCatalog.java","lineNumber":333,"sourceCode":"                    \"Failed to drop BigQuery table: \" + tablePath.getFullName(), e);\n        }\n    }\n\n    @Override\n    public void createDatabase(TablePath tablePath, boolean ignoreIfExists)\n            throws DatabaseAlreadyExistException, CatalogException {\n        String databaseName = getDatasetName(tablePath);\n        if (databaseExists(databaseName)) {\n            if (ignoreIfExists) {\n                return;\n            }\n            throw new DatabaseAlreadyExistException(catalogName, databaseName);\n        }\n        try {\n            bigquery.create(DatasetInfo.newBuilder(databaseName).build());\n            log.info(\"BigQuery Dataset (database) '{}' created successfully.\", databaseName);\n        } catch (Exception e) {\n            throw new CatalogException(\"Failed to create BigQuery dataset: \" + databaseName, e);\n        }\n    }\n\n    @Override\n    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)\n            throws DatabaseNotExistException, CatalogException {\n        String databaseName = getDatasetName(tablePath);\n        if (!databaseExists(databaseName)) {\n            if (ignoreIfNotExists) {\n                return;\n            }\n            throw new DatabaseNotExistException(catalogName, databaseName);\n        }\n        try {\n            bigquery.delete(databaseName, BigQuery.DatasetDeleteOption.deleteContents());\n            log.info(\"BigQuery Dataset (database) '{}' dropped successfully.\", databaseName);\n        } catch (Exception e) {\n            throw new CatalogException(\"Failed to drop BigQuery dataset: \" + databaseName, e);","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-bigquery/src/main/java/org/apache/seatunnel/connectors/bigquery/catalog/BigQueryCatalog.java#L315-L351","documentation":"This CatalogException is thrown by BigQueryCatalog.createDatabase when the Google BigQuery client's bigquery.create(DatasetInfo...) call fails for any reason. It wraps the underlying exception (auth failure, quota, permission, name conflict, network) while naming the dataset that could not be created. It is the SeaTunnel catalog-layer translation of a BigQuery API failure during database (dataset) creation.","triggerScenarios":"Calling createDatabase(tablePath, ignoreIfNotExists) on a BigQueryCatalog when the service account lacks bigquery.datasets.create permission, the dataset already exists and the API rejects it, the project ID is wrong, credentials are missing/invalid, or the BigQuery API call hits a quota or network error.","commonSituations":"Wrong GOOGLE_APPLICATION_CREDENTIALS or a service account without BigQuery Admin role; dataset name colliding with an existing one (createDatabase does not check existence beforehand in the failing branch); misconfigured project; regional dataset restrictions; transient 429/5xx from the BigQuery API.","solutions":["Check the wrapped cause 'e' in the stack trace for the real BigQuery error (409 conflict, 403 permission, 401 auth)","Verify the service account has roles/bigquery.dataOwner or bigquery.admin on the target project","Confirm the dataset does not already exist (or call catalog.databaseExists first) and the project ID in catalog options is correct","Validate GOOGLE_APPLICATION_CREDENTIALS points to a valid key file and retry transient network/quota failures"],"exampleFix":"// before\ncatalog.createDatabase(tablePath, false);\n// after\nif (!catalog.databaseExists(tablePath)) {\n    catalog.createDatabase(tablePath, false);\n}","handlingStrategy":"validation","validationCode":"if (catalog.databaseExists(tablePath)) {\n    LOG.info(\"Dataset \" + tablePath.getDatabaseName() + \" already exists, skipping create\");\n} else {\n    catalog.createDatabase(tablePath, false);\n}","typeGuard":null,"tryCatchPattern":"try {\n    catalog.createDatabase(tablePath, false);\n} catch (CatalogException e) {\n    LOG.error(\"Dataset create failed; cause: \" + e.getCause(), e);\n    throw e;\n}","preventionTips":["Check databaseExists before createDatabase to handle idempotently","Grant the service account bigquery.datasets.create (dataOwner/admin role)","Verify credentials (GOOGLE_APPLICATION_CREDENTIALS) resolve before submitting the job","Inspect the wrapped cause for 409/403/401 to distinguish conflicts from permission issues"],"tags":["bigquery","catalog","dataset-creation","gcp"],"backgroundTag":"database-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}