{"record":{"id":"e13f0495e9567611","repo":"apache/beam","slug":"attempting-to-create-catalog-s-with-unexpected-calcite","errorCode":null,"errorMessage":"Attempting to create catalog '%s' with unexpected Calcite Schema of type %s","messagePattern":"Attempting to create 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/SqlCreateCatalog.java","lineNumber":119,"sourceCode":"                \"Unexpected properties entry '%s' of class '%s'\", property, property.getClass()));\n        SqlNodeList kv = ((SqlNodeList) property);\n\n        kv.get(0).unparse(writer, leftPrec, rightPrec); // key\n        writer.keyword(\"=\");\n        kv.get(1).unparse(writer, leftPrec, rightPrec); // value\n      }\n      writer.keyword(\")\");\n    }\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    String typeStr = checkArgumentNotNull(SqlDdlNodes.getString(type));\n\n    if (!(schema instanceof CatalogManagerSchema)) {\n      throw SqlUtil.newContextException(\n          catalogName.getParserPosition(),\n          RESOURCE.internal(\n              \"Attempting to create catalog '\"\n                  + SqlDdlNodes.name(catalogName)\n                  + \"' with unexpected Calcite Schema of type \"\n                  + schema.getClass()));\n    }\n\n    ((CatalogManagerSchema) schema)\n        .createCatalog(catalogName, typeStr, parseProperties(), getReplace(), ifNotExists);\n  }\n\n  private Map<String, String> parseProperties() {\n    if (properties == null || properties.isEmpty()) {\n      return Collections.emptyMap();\n    }\n\n    Map<String, String> props = new HashMap<>();","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlCreateCatalog.java#L101-L137","documentation":"Thrown by SqlCreateCatalog.execute when the schema resolved for the catalog name is not a CatalogManagerSchema. CREATE CATALOG can only be executed when the target resolves to Beam's catalog manager schema; any other Calcite Schema type is rejected.","triggerScenarios":"Executing `CREATE CATALOG name ...` where SqlDdlNodes.schema(context, true, catalogName) resolves to a schema that is not an instance of CatalogManagerSchema.","commonSituations":"Issuing CREATE CATALOG in a session whose current schema is a plain BeamCalciteSchema, nested catalog names resolving to a database schema, or mixing Beam SQL with an external Calcite setup.","solutions":["Run CREATE CATALOG only at the top-level catalog manager scope (no database prefix).","Remove any database qualifier from the catalog name so it resolves to CatalogManagerSchema.","Verify the Beam SQL session is initialized with the catalog manager schema enabled.","Use CREATE DATABASE for database-level DDL instead."],"exampleFix":"// before\nCREATE CATALOG mydb.mycatalog ...; -- resolves to a database schema\n// after\nCREATE CATALOG mycatalog TYPE '...';","handlingStrategy":"validation","validationCode":"// Java: ensure the target schema is the catalog manager before CREATE CATALOG\nSchema schema = pair.left.schema;\nif (!(schema instanceof CatalogManagerSchema)) {\n  throw new IllegalStateException(\"CREATE CATALOG must target the catalog manager, got \" + schema.getClass());\n}","typeGuard":"boolean isCatalogManagerSchema(Schema s) { return s instanceof org.apache.beam.sdk.extensions.sql.impl.CatalogManagerSchema; }","tryCatchPattern":null,"preventionTips":["Issue CREATE CATALOG with an unqualified catalog name.","Initialize the SQL session with Beam's catalog manager schema.","Use CREATE DATABASE for names that include a database component.","CREATE the catalog once at startup, not per-query."],"tags":["sql","ddl","catalog","type-mismatch"],"backgroundTag":"type-mismatch","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"}