apache/beam · error · SqlUtil.newContextException

Table ' ' not found

Error message

Table '%s' not found

What it means

Thrown when DROP TABLE's target table is not found in the resolved BeamCalciteSchema (getTable returns null) and IF EXISTS was not given. Like SqlDropObject's variant, it surfaces Calcite's tableNotFound error at the parser position.

Solutions

  1. Use DROP TABLE IF EXISTS <name>
  2. Qualify the table with the correct catalog/database
  3. Re-create the table if the drop should have followed a create that failed
  4. Check for case/quoting differences in the identifier

Example fix

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

Strategy: validation

Validate before calling

boolean exists = beamCalciteSchema.getTable("external_orders") != null;
if (!exists) { /* skip drop */ }

Prevention

When it happens

Trigger: `DROP TABLE <name>` against a BeamCalciteSchema that has no table with that simple name, without IF EXISTS.

Common situations: Re-running cleanup DDL; table was already dropped or never created in this session's schema; using an unqualified name while the table lives in another database/catalog.

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/74513379553b11c5. Report an issue: GitHub.

Appendix: source

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

          pathOverride.catalog() != null
              ? catalogManagerSchema.getCatalogSchema(pathOverride)
              : catalogManagerSchema.getCurrentCatalogSchema();
      beamCalciteSchema = catalogSchema.getDatabaseSchema(pathOverride);
    } else if (schema instanceof BeamCalciteSchema) {
      beamCalciteSchema = (BeamCalciteSchema) schema;
    } else {
      throw SqlUtil.newContextException(
          name.getParserPosition(),
          RESOURCE.internal(
              "Attempting to drop a table using unexpected Calcite Schema of type "
                  + schema.getClass()));
    }

    if (beamCalciteSchema.getTable(pair.right) == null) {
      // Table does not exist.
      if (!ifExists) {
        // They did not specify IF EXISTS, so give error.
        throw SqlUtil.newContextException(
            name.getParserPosition(), RESOURCE.tableNotFound(name.toString()));
      }
      return;
    }

    beamCalciteSchema.getTableProvider().dropTable(pair.right);
  }
}

// End SqlDropTable.java

View on GitHub (pinned to 12126d8942)