{"record":{"id":"d0af0d2b8973bfc9","repo":"apache/beam","slug":"attempting-to-drop-a-catalog-s-with-unexpected-calcite","errorCode":null,"errorMessage":"Attempting to drop a catalog '%s' with unexpected Calcite Schema of type %s","messagePattern":"Attempting to drop a catalog '(.+?)' with unexpected Calcite Schema of type (.+?)","errorType":"validation","errorClass":"SqlUtil.newContextException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlDropCatalog.java","lineNumber":64,"sourceCode":"    this.catalogName = SqlDdlNodes.getIdentifier(catalogName, pos);\n  }\n\n  @Override\n  public void unparse(SqlWriter writer, int leftPrec, int rightPrec) {\n    writer.keyword(getOperator().getName());\n    if (ifExists) {\n      writer.keyword(\"IF EXISTS\");\n    }\n    catalogName.unparse(writer, leftPrec, rightPrec);\n  }\n\n  @Override\n  public void execute(CalcitePrepare.Context context) {\n    final Pair<CalciteSchema, String> pair = SqlDdlNodes.schema(context, true, catalogName);\n    Schema schema = pair.left.schema;\n\n    if (!(schema instanceof CatalogManagerSchema)) {\n      throw SqlUtil.newContextException(\n          catalogName.getParserPosition(),\n          RESOURCE.internal(\n              \"Attempting to drop a catalog '\"\n                  + SqlDdlNodes.name(catalogName)\n                  + \"' with unexpected Calcite Schema of type \"\n                  + schema.getClass()));\n    }\n\n    ((CatalogManagerSchema) schema).dropCatalog(catalogName, ifExists);\n  }\n\n  @Override\n  public List<SqlNode> getOperandList() {\n    return ImmutableList.of(catalogName);\n  }\n}\n","sourceCodeStart":46,"sourceCodeEnd":81,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlDropCatalog.java#L46-L81","documentation":"DROP CATALOG must resolve its target to a CatalogManagerSchema. If the resolved Calcite schema is any other type, execute() aborts with an internal error identifying the actual schema class, because only catalog-manager-backed schemas support catalog drops.","triggerScenarios":"`DROP CATALOG <name>` where the name resolves to a non-CatalogManagerSchema (e.g. a plain or BeamCalciteSchema), typically when the multi-catalog feature is not enabled or the name binds to the wrong schema.","commonSituations":"Using DROP CATALOG in a default single-catalog Beam SQL setup; typos causing resolution to a database schema instead of a catalog; mixing sessions with and without catalog support.","solutions":["Only run DROP CATALOG against catalogs created via CREATE CATALOG with CatalogManagerSchema","Check the catalog/database name for typos","Use DROP DATABASE/DROP SCHEMA for non-catalog objects","Verify the session has the catalog manager enabled"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!(schema instanceof CatalogManagerSchema)) {\n  throw new IllegalStateException(\"DROP CATALOG requires a catalog-managed session\");\n}","typeGuard":"boolean supportsCatalogs(Schema s) { return s instanceof CatalogManagerSchema; }","tryCatchPattern":null,"preventionTips":["Use DROP CATALOG only in sessions with catalog management enabled","Qualify catalog names precisely and check typos","Use DROP DATABASE for database-level objects"],"tags":["sql","ddl","catalog","internal-error"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}