apache/beam · error · SqlUtil.newContextException
Cannot drop catalog: ' ' not found.
Error message
Cannot drop catalog: '%s' not found.
What it means
Raised by DROP CATALOG when the target catalog does not exist and IF EXISTS was not specified. Beam throws a Calcite context exception at the statement's parser position; with IF EXISTS the drop is silently ignored.
Solutions
- Use DROP CATALOG IF EXISTS name to make the statement idempotent
- Verify the catalog name with the available catalogs before dropping
- Skip the statement if the catalog was already removed
Example fix
// before DROP CATALOG my_catalog; // after DROP CATALOG IF EXISTS my_catalog;
Defensive patterns
Strategy: try-catch
Validate before calling
// make idempotent at the source String sql = "DROP CATALOG IF EXISTS " + name;
Try / catch
try {
stmt.execute("DROP CATALOG " + name);
} catch (Exception e) {
if (e.getMessage().contains("not found")) { /* already dropped; ignore */ }
} Prevention
- Use IF EXISTS in all teardown scripts
- Do not assume catalog existence across environments
When it happens
Trigger: Executing `DROP CATALOG name` where catalogManager.getCatalog(name) == null and ifExists=false.
Common situations: Teardown scripts assuming catalogs exist; double-execution of DROP scripts; dropping a catalog that was created under a different name.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Cannot use catalog: ' ' not found.
- Catalog ' ' already exists.
- Unable to drop active catalog
- Attempting to alter catalog
- Attempting to create catalog
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/ca7d01303773020a.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/CatalogManagerSchema.java:122
throw SqlUtil.newContextException(
catalogIdentifier.getParserPosition(),
RESOURCE.internal(String.format("Cannot use catalog: '%s' not found.", name)));
}
if (catalogManager.currentCatalog().name().equals(name)) {
LOG.info("Catalog '{}' is already in use.", name);
return;
}
catalogManager.useCatalog(name);
LOG.info("Switched to catalog '{}' (type: {})", name, catalogManager.currentCatalog().type());
}
public void dropCatalog(SqlIdentifier identifier, boolean ifExists) {
String name = SqlDdlNodes.name(identifier);
if (catalogManager.getCatalog(name) == null) {
if (!ifExists) {
throw SqlUtil.newContextException(
identifier.getParserPosition(),
RESOURCE.internal(String.format("Cannot drop catalog: '%s' not found.", name)));
}
LOG.info("Ignoring 'DROP CATALOG` call for non-existent catalog: {}", name);
return;
}
if (catalogManager.currentCatalog().name().equals(name)) {
throw SqlUtil.newContextException(
identifier.getParserPosition(),
RESOURCE.internal(
String.format(
"Unable to drop active catalog '%s'. Please switch to another catalog first.",
name)));
}
catalogManager.dropCatalog(name);
LOG.info("Successfully dropped catalog '{}'", name);View on GitHub (pinned to 12126d8942)