{"record":{"id":"cf24759e9ac15940","repo":"apache/beam","slug":"attempting-to-drop-a-table-using-unexpected-calcite-schema","errorCode":null,"errorMessage":"Attempting to drop a table using unexpected Calcite Schema of type %s","messagePattern":"Attempting to drop a table using 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/SqlAlterTable.java","lineNumber":106,"sourceCode":"\n  @Override\n  public void execute(CalcitePrepare.Context context) {\n    final Pair<CalciteSchema, String> pair = SqlDdlNodes.schema(context, true, name);\n    TableName pathOverride = TableName.create(name.toString());\n    Schema schema = pair.left.schema;\n\n    BeamCalciteSchema beamCalciteSchema;\n    if (schema instanceof CatalogManagerSchema) {\n      CatalogManagerSchema catalogManagerSchema = (CatalogManagerSchema) schema;\n      CatalogSchema catalogSchema =\n          pathOverride.catalog() != null\n              ? catalogManagerSchema.getCatalogSchema(pathOverride)\n              : catalogManagerSchema.getCurrentCatalogSchema();\n      beamCalciteSchema = catalogSchema.getDatabaseSchema(pathOverride);\n    } else if (schema instanceof BeamCalciteSchema) {\n      beamCalciteSchema = (BeamCalciteSchema) schema;\n    } else {\n      throw SqlUtil.newContextException(\n          name.getParserPosition(),\n          RESOURCE.internal(\n              \"Attempting to drop a table using unexpected Calcite Schema of type \"\n                  + schema.getClass()));\n    }\n\n    if (beamCalciteSchema.getTable(pair.right) == null) {\n      // Table does not exist.\n      throw SqlUtil.newContextException(\n          name.getParserPosition(), RESOURCE.tableNotFound(name.toString()));\n    }\n\n    Map<String, String> setPropsMap = SqlDdlNodes.getStringMap(setProps);\n    List<String> resetPropsList = SqlDdlNodes.getStringList(resetProps);\n    List<String> columnsToDropList = SqlDdlNodes.getStringList(columnsToDrop);\n    List<String> partitionsToAddList = SqlDdlNodes.getStringList(partitionsToAdd);\n    List<String> partitionsToDropList = SqlDdlNodes.getStringList(partitionsToDrop);\n","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlAlterTable.java#L88-L124","documentation":"Thrown by SqlAlterTable.execute (DROP TABLE path) when the resolved schema is neither a CatalogManagerSchema nor a BeamCalciteSchema. Dropping a table requires the schema to be one of Beam's supported schema types; any other Calcite Schema implementation is rejected.","triggerScenarios":"Executing `ALTER TABLE name DROP ...` (or the drop branch of SqlAlterTable) where pair.left.schema's concrete class is neither CatalogManagerSchema nor BeamCalciteSchema.","commonSituations":"Pointing the DDL at a third-party/foreign Calcite schema, running the statement against a schema registered by another framework, or referencing the wrong database/catalog path.","solutions":["Ensure the target schema is a Beam schema (BeamCalciteSchema or CatalogManagerSchema).","Qualify the table name with a Beam-managed database/catalog path.","Register the table within a Beam catalog rather than a raw Calcite schema.","Check the statement's name resolution (catalog.database/table) for typos."],"exampleFix":"// before\nALTER TABLE foreignSchema.mytable DROP COLUMN c; -- schema is a foreign Calcite Schema\n// after\nALTER TABLE mydb.mytable DROP COLUMN c; -- mydb resolves to a BeamCalciteSchema","handlingStrategy":"type-guard","validationCode":"// Java: confirm the resolved schema is Beam-managed before ALTER TABLE\nSchema schema = pair.left.schema;\nboolean ok = schema instanceof CatalogManagerSchema || schema instanceof BeamCalciteSchema;\nif (!ok) throw new IllegalStateException(\"unsupported schema: \" + schema.getClass());","typeGuard":"boolean isBeamSchema(Schema s) {\n  return s instanceof org.apache.beam.sdk.extensions.sql.impl.BeamCalciteSchema\n      || s instanceof org.apache.beam.sdk.extensions.sql.impl.CatalogManagerSchema;\n}","tryCatchPattern":null,"preventionTips":["Register tables only under Beam-managed schemas.","Qualify ALTER TABLE names with Beam catalog/database paths.","Avoid pointing DDL at foreign Calcite schema implementations.","Verify name resolution path when integrating external Calcite setups."],"tags":["sql","ddl","table","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"}