{"record":{"id":"2a14ed4225a93f8d","repo":"apache/beam","slug":"table-s-not-found","errorCode":null,"errorMessage":"Table '%s' not found","messagePattern":"Table '(.+?)' not found","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":115,"sourceCode":"      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\n    AlterTableOps alterOps =\n        beamCalciteSchema.getTableProvider().alterTable(SqlDdlNodes.name(name));\n\n    if (!setPropsMap.isEmpty() || !resetPropsList.isEmpty()) {\n      validateNonOverlappingProps(setPropsMap, resetPropsList);\n\n      alterOps.updateTableProperties(setPropsMap, resetPropsList);\n    }\n    if (!columnsToDropList.isEmpty() || (columnsToAdd != null && !columnsToAdd.isEmpty())) {","sourceCodeStart":97,"sourceCodeEnd":133,"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#L97-L133","documentation":"Thrown by SqlAlterTable.execute when beamCalciteSchema.getTable(pair.right) returns null, i.e. the table named in the ALTER TABLE statement does not exist in the resolved schema. Calcite reports it via RESOURCE.tableNotFound with the parser position.","triggerScenarios":"Executing `ALTER TABLE name ...` where the resolved BeamCalciteSchema has no table whose name matches pair.right (the table part of the identifier).","commonSituations":"Typos in table names, running ALTER before CREATE TABLE DDL, tables registered under a different database than the one resolved, or case-sensitive name mismatches.","solutions":["Create the table first with CREATE TABLE (or CREATE EXTERNAL TABLE) before altering.","Fix the table name spelling/case and qualify it with the correct database.","Verify the table exists in the resolved schema path (catalog.database).","Re-run any pipeline/steps that register the table if it was dropped elsewhere."],"exampleFix":"// before\nALTER TABLE mydb.orders ADD COLUMN amount DOUBLE; -- 'orders' missing\n// after\nCREATE TABLE mydb.orders (id BIGINT) ...;\nALTER TABLE mydb.orders ADD COLUMN amount DOUBLE;","handlingStrategy":"validation","validationCode":"// Java: check table presence before ALTER TABLE\nCalciteSchema dbSchema = ...; // resolved BeamCalciteSchema\nif (dbSchema.getTable(tableName) == null) {\n  stmt.execute(\"CREATE TABLE ... \"); // or fail fast with a clear message\n}\nstmt.execute(\"ALTER TABLE \" + tableName + \" ...\");","typeGuard":null,"tryCatchPattern":"// Java\ncatch (SQLException e) {\n  if (e.getMessage().contains(\"Table '\")) {\n    throw new IllegalStateException(\"Table missing; run CREATE TABLE first\", e);\n  } else throw e;\n}","preventionTips":["Run CREATE TABLE before ALTER TABLE in every script.","Qualify table names with the correct database.","Keep table-name constants centralized to avoid typos.","Check case sensitivity conventions of the catalog."],"tags":["sql","ddl","table","not-found"],"backgroundTag":"entity-not-found","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"}