prestodb/presto · error · PrestoException
INVALID_VIEW
INVALID_VIEW
Error message
View already exists as data table
What it means
Thrown by createView when the requested view name collides with an existing DATA TABLE (not a view) in the same schema. The connector distinguishes tables from views in its metadata, and creating a view on top of a table name is invalid, so it fails with INVALID_VIEW before any metadata is written.
Source
Thrown at presto-accumulo/src/main/java/com/facebook/presto/accumulo/AccumuloClient.java:547
}
if (tableManager.exists(newTable.getMetricsTableName())) {
throw new PrestoException(ACCUMULO_TABLE_EXISTS, format("Table %s already exists", newTable.getMetricsTableName()));
}
tableManager.renameAccumuloTable(oldTable.getIndexTableName(), newTable.getIndexTableName());
tableManager.renameAccumuloTable(oldTable.getMetricsTableName(), newTable.getMetricsTableName());
}
public void createView(SchemaTableName viewName, String viewData)
{
if (getSchemaNames().contains(viewName.getSchemaName())) {
if (getViewNames(viewName.getSchemaName()).contains(viewName.getTableName())) {
throw new PrestoException(ALREADY_EXISTS, "View already exists");
}
if (getTableNames(viewName.getSchemaName()).contains(viewName.getTableName())) {
throw new PrestoException(INVALID_VIEW, "View already exists as data table");
}
}
metaManager.createViewMetadata(new AccumuloView(viewName.getSchemaName(), viewName.getTableName(), viewData));
}
public void createOrReplaceView(SchemaTableName viewName, String viewData)
{
if (getView(viewName) != null) {
metaManager.deleteViewMetadata(viewName);
}
metaManager.createViewMetadata(new AccumuloView(viewName.getSchemaName(), viewName.getTableName(), viewData));
}
public void dropView(SchemaTableName viewName)
{
metaManager.deleteViewMetadata(viewName);View on GitHub (pinned to 55bb57d202)
Solutions
- Choose a different name for the view
- Drop or rename the existing data table if it is no longer needed
- Move the data table to another schema/name, then create the view
- Verify with SHOW TABLES vs SHOW VIEWS which object occupies the name
Example fix
// before CREATE VIEW my_schema.events AS SELECT ...; -- my_schema.events is a data table // after ALTER TABLE my_schema.events RENAME TO my_schema.events_raw; CREATE VIEW my_schema.events AS SELECT ...;
Defensive patterns
Strategy: validation
Validate before calling
-- Pre-check that the name is not occupied by a table SELECT count(*) FROM system.jdbc.tables WHERE table_schema = 'my_schema' AND table_name = 'my_view'; -- expect 0
Type guard
boolean nameNotATable(SchemaTableName name) {
return !getSchemaNames().contains(name.getSchemaName())
|| !getTableNames(name.getSchemaName()).contains(name.getTableName());
} Try / catch
try {
client.createView(viewName, viewData);
} catch (PrestoException e) {
if (e.getErrorCode().getName().equals("INVALID_VIEW")) {
// a data table holds this name: rename/drop the table or pick a new view name
} else {
throw e;
}
} Prevention
- Maintain separate naming conventions for tables vs views (e.g. vw_ prefix)
- Run SHOW TABLES and SHOW VIEWS before creating a view
- Remove or rename stale tables left by failed migrations before re-running scripts
- Document and enforce that view names never shadow table names in a schema
When it happens
Trigger: Calling createView(viewName, viewData) where getTableNames(viewName.getSchemaName()).contains(viewName.getTableName()) is true — the target name is an existing Accumulo-backed data table.
Common situations: Naming a view the same as a table that was created earlier in the schema; migration scripts that convert tables to views but leave the old table in place; confusion after sync/rename operations left a table with the intended view name.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/7ea9732a74099f2d.
Report an issue: GitHub.