apache/beam · error · SqlUtil.newContextException
Attempting to alter catalog
Error message
Attempting to alter catalog '%s' with unexpected Calcite Schema of type %s
What it means
Thrown by SqlAlterCatalog.execute when the resolved schema for the catalog name is not a CatalogManagerSchema. ALTER CATALOG can only operate on Beam's CatalogManagerSchema; anything else (e.g. a plain BeamCalciteSchema) is rejected with this type-mismatch message.
Solutions
- Target a catalog registered in Beam's CatalogManagerSchema, not a plain schema.
- Create the catalog first with CREATE CATALOG so it resolves to CatalogManagerSchema.
- Check the fully qualified name resolves to the intended managed catalog.
- Use ALTER DATABASE/TABLE statements for non-catalog schemas.
Example fix
// before ALTER CATALOG default SET 'k'='v'; -- resolves to non-manager schema // after CREATE CATALOG IF NOT EXISTS mycatalog; ALTER CATALOG mycatalog SET 'k'='v';
Defensive patterns
Strategy: validation
Validate before calling
// Java: verify schema type before ALTER CATALOG
Schema schema = calciteSchema.schema;
if (!(schema instanceof CatalogManagerSchema)) {
throw new IllegalStateException("ALTER CATALOG requires a managed catalog, got " + schema.getClass());
} Type guard
boolean isManagedCatalog(Schema s) { return s instanceof org.apache.beam.sdk.extensions.sql.impl.CatalogManagerSchema; } Prevention
- Only run ALTER CATALOG against catalogs registered in the catalog manager.
- Create the catalog first via CREATE CATALOG.
- Do not qualify catalog names with database paths.
- Log schema.getClass() when DDL resolution seems off.
When it happens
Trigger: Executing `ALTER CATALOG name ...` where SqlDdlNodes.schema(context, true, name) resolves to a CalciteSchema whose schema object is not an instance of CatalogManagerSchema.
Common situations: Running ALTER CATALOG against a catalog defined outside Beam's catalog manager (a raw BeamCalciteSchema), mixing catalog implementations, or referencing the current/default schema that is not a managed catalog.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Attempting to create catalog
- Attempting to create database
- Attempting to drop a catalog
- Attempting to drop a table using unexpected Calcite Schema…
- Cannot drop catalog: ' ' not found.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/daede57ca89bac17.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/parser/SqlAlterCatalog.java:75
public SqlAlterCatalog(
SqlParserPos pos,
@Nullable String scope,
SqlNode name,
@Nullable SqlNodeList setProps,
@Nullable SqlNodeList resetProps) {
super(pos, scope);
this.name = SqlDdlNodes.getIdentifier(name, pos);
this.setProps = setProps;
this.resetProps = resetProps;
}
@Override
public void execute(CalcitePrepare.Context context) {
final Pair<CalciteSchema, String> pair = SqlDdlNodes.schema(context, true, name);
Schema schema = pair.left.schema;
if (!(schema instanceof CatalogManagerSchema)) {
throw SqlUtil.newContextException(
name.getParserPosition(),
RESOURCE.internal(
"Attempting to alter catalog '"
+ SqlDdlNodes.name(name)
+ "' with unexpected Calcite Schema of type "
+ schema.getClass()));
}
CatalogSchema catalogSchema =
((CatalogManagerSchema) schema).getCatalogSchema(SqlDdlNodes.getString(name));
Map<String, String> setPropsMap = SqlDdlNodes.getStringMap(setProps);
Collection<String> resetPropsList = SqlDdlNodes.getStringList(resetProps);
ImmutableList.Builder<String> overlappingPropsBuilder = ImmutableList.builder();
resetPropsList.stream().filter(setPropsMap::containsKey).forEach(overlappingPropsBuilder::add);
List<String> overlappingProps = overlappingPropsBuilder.build();
checkState(View on GitHub (pinned to 12126d8942)