prestodb/presto · error · PrestoException
SYNTAX_ERROR
SYNTAX_ERROR
Error message
Cannot rename tables across catalogs
What it means
MetadataManager.renameTable rejects RENAME attempts where the destination qualified name belongs to a different catalog than the table's current connector. Presto cannot move a table between connectors, so cross-catalog renames throw SYNTAX_ERROR. Renames must stay within the same catalog (and hence the same connector).
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/metadata/MetadataManager.java:789
{
ConnectorId partitioningConnectorId = partitioningMetadata.getPartitioningHandle().getConnectorId()
.orElseThrow(() -> new IllegalArgumentException("connectorId is expected to be present in the connector partitioning handle"));
checkArgument(
connectorId.equals(partitioningConnectorId),
"Unexpected partitioning handle connector: %s. Expected: %s.",
partitioningConnectorId,
connectorId);
return new ConnectorPartitioningMetadata(partitioningMetadata.getPartitioningHandle().getConnectorHandle(), partitioningMetadata.getPartitionColumns());
}
@Override
public void renameTable(Session session, TableHandle tableHandle, QualifiedObjectName newTableName)
{
String catalogName = newTableName.getCatalogName();
CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, catalogName);
ConnectorId connectorId = catalogMetadata.getConnectorId();
if (!tableHandle.getConnectorId().equals(connectorId)) {
throw new PrestoException(SYNTAX_ERROR, "Cannot rename tables across catalogs");
}
ConnectorMetadata metadata = catalogMetadata.getMetadata();
metadata.renameTable(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle(),
toSchemaTableName(newTableName.getSchemaName(), newTableName.getObjectName()));
}
@Override
public void setTableProperties(Session session, TableHandle tableHandle, Map<String, Object> properties)
{
ConnectorId connectorId = tableHandle.getConnectorId();
ConnectorMetadata metadata = getMetadataForWrite(session, connectorId);
metadata.setTableProperties(session.toConnectorSession(connectorId), tableHandle.getConnectorHandle(), properties);
}
@Override
public void renameColumn(Session session, TableHandle tableHandle, ColumnHandle source, String target)View on GitHub (pinned to 55bb57d202)
Solutions
- Rename within the same catalog only: ALTER TABLE cat.db.old RENAME TO cat.db.new
- To move data across catalogs, CREATE TABLE new_cat.db.new AS SELECT * FROM old_cat.db.old, then drop the source
- Use a connector-specific export/import or storage-level copy for large cross-catalog moves
- Update scripts to resolve the target catalog from the source table's catalog
Example fix
// before ALTER TABLE hive.default.events RENAME TO iceberg.default.events; -- cross-catalog // after CREATE TABLE iceberg.default.events AS SELECT * FROM hive.default.events; DROP TABLE hive.default.events;
Defensive patterns
Strategy: validation
Validate before calling
if (!newTableName.getCatalogName().equals(tableHandle.getConnectorId().getCatalogName())) {
throw new IllegalArgumentException("Rename target must stay in catalog " + tableHandle.getConnectorId());
} Type guard
boolean sameCatalog(TableHandle h, QualifiedObjectName target) { return target.getCatalogName().equals(h.getConnectorId().getCatalogName()); } Try / catch
try { metadataManager.renameTable(session, handle, newName); }
catch (PrestoException e) { if (SYNTAX_ERROR.getCode() == e.getErrorCode()) { /* fall back to CTAS + drop for cross-catalog moves */ } else throw e; } Prevention
- Only rename within the same catalog; use CTAS for cross-catalog moves
- Generate target names in scripts from the source table's catalog
- Educate users that schemas can differ but catalogs cannot on RENAME
When it happens
Trigger: Running ALTER TABLE ... RENAME TO <catalog>.<other>.<name> (or calling renameTable) where newTableName.getCatalogName() differs from tableHandle.getConnectorId()'s catalog.
Common situations: Users attempting to 'move' a table from one catalog to another via rename; scripts that build fully-qualified target names dynamically; confusion between schemas (allowed) and catalogs (not allowed) during renames.
Related errors
- MISSING_CATALOG
- INVALID_TABLE_PROPERTY
- Invalid time from server:
- Expected column to be a time type but is
- Invalid timestamp from server:
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/69394c2e270ae4aa.
Report an issue: GitHub.