apache/beam · error · SqlUtil.newContextException

Table ' ' not found

Error message

Table '%s' not found

What it means

Thrown by DROP TABLE (within SqlDropObject) when the table to drop does not exist in the schema (removeTable/tableProvider.dropTable report non-existence) and IF EXISTS was not specified. Calcite's RESOURCE.tableNotFound produces the parse-context error.

Solutions

  1. Add IF EXISTS: DROP TABLE IF EXISTS <name>
  2. Verify the table name and catalog/database qualification
  3. List existing tables to confirm the name
  4. Check quoting/case sensitivity of the identifier

Example fix

// before
DROP TABLE orders;
// after
DROP TABLE IF EXISTS orders;
Defensive patterns

Strategy: validation

Validate before calling

boolean exists = schema.getTableNames().stream()
    .anyMatch(n -> n.getSimple().equalsIgnoreCase("orders"));
if (!exists) { /* skip drop */ }

Prevention

When it happens

Trigger: `DROP TABLE <name>` where the table is absent from the resolved schema and IF EXISTS is omitted.

Common situations: Idempotent cleanup scripts re-run; dropping a table created in a different catalog/database path; case-sensitivity or quoting mismatches in the table 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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/134f1351b7810cef. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlDropObject.java:85

      schema = schema.getSubSchema(p, true);
      if (schema == null) {
        throw new AssertionError(String.format("Got null sub-schema for path '%s' in %s", p, path));
      }
    }
    final boolean existed;
    switch (getKind()) {
      case DROP_TABLE:
        if (schema.schema instanceof BeamCalciteSchema) {
          BeamCalciteSchema beamSchema = (BeamCalciteSchema) schema.schema;
          existed = beamSchema.getTableProvider().getTable(name.getSimple()) != null;
          if (existed) {
            beamSchema.getTableProvider().dropTable(name.getSimple());
          }
        } else {
          existed = schema.removeTable(name.getSimple());
        }
        if (!existed && !ifExists) {
          throw SqlUtil.newContextException(
              name.getParserPosition(), RESOURCE.tableNotFound(name.getSimple()));
        }
        break;
      default:
        throw new AssertionError(getKind());
    }
  }
}

// End SqlDropObject.java

View on GitHub (pinned to 12126d8942)