prestodb/presto · error · PrestoException

NOT_PERMITTED

NOT_PERMITTED

Error message

Schema is required to list tables

What it means

LarkSheetsMetadata.listTables requires a concrete schema because listing tables means enumerating sheets of a specific Lark spreadsheet (schema = spreadsheet token). When listTables is called with an empty Optional<String> schemaName (e.g. SHOW TABLES without a schema, or connector-wide table listing), there is no spreadsheet to inspect, so the connector throws StandardErrorCode.NOT_PERMITTED with 'Schema is required to list tables'.

Source

Thrown at presto-lark-sheets/src/main/java/com/facebook/presto/lark/sheets/LarkSheetsMetadata.java:168

        LarkSheetsTableHandle sheetsTable = (LarkSheetsTableHandle) table;
        List<LarkSheetsColumnHandle> sheetsColumns = getColumns(sheetsTable);
        List<ColumnMetadata> columnMetadatas = toColumnMetadatas(session, sheetsColumns);
        return new ConnectorTableMetadata(sheetsTable.getSchemaTableName(), columnMetadatas);
    }

    @Override
    public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle)
    {
        LarkSheetsTableHandle sheetsTable = (LarkSheetsTableHandle) tableHandle;
        List<LarkSheetsColumnHandle> columns = getColumns(sheetsTable);
        return columns.stream().collect(toImmutableMap(LarkSheetsColumnHandle::getName, Function.identity()));
    }

    @Override
    public List<SchemaTableName> listTables(ConnectorSession session, Optional<String> schemaName)
    {
        if (!schemaName.isPresent()) {
            throw new PrestoException(NOT_PERMITTED, "Schema is required to list tables");
        }
        LarkSheetsSchema schema = requireVisibleSchema(session, schemaName.get());
        checkSchemaReadable(schema);
        return api.getMetaInfo(schema.getToken())
                .getSheets()
                .stream()
                .sorted(SheetInfo.indexComparator())
                .map(sheet -> new SchemaTableName(schema.getName(), sheet.getTitle()))
                .collect(toImmutableList());
    }

    @Override
    public ColumnMetadata getColumnMetadata(ConnectorSession session, ConnectorTableHandle tableHandle, ColumnHandle columnHandle)
    {
        return ((LarkSheetsColumnHandle) columnHandle).toColumnMetadata();
    }

    @Override

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Qualify the listing: run SHOW TABLES FROM <schema> (the schema being the Lark Sheets schema/spreadsheet name).
  2. USE <catalog>.<schema> first, then SHOW TABLES.
  3. In code, pass Optional.of(schemaName) instead of Optional.empty() to listTables.
  4. Configure the connector to limit catalog-wide scans if your tooling cannot scope to a schema.

Example fix

-- before
SHOW TABLES;
-- after
USE lark_sheets.my_spreadsheet_schema;
SHOW TABLES;
Defensive patterns

Strategy: validation

Validate before calling

if (schemaName == null || schemaName.isEmpty()) {
    throw new IllegalArgumentException("Pass a schema: SHOW TABLES FROM lark_sheets.<schema>");
}

Prevention

When it happens

Trigger: SHOW TABLES executed while not bound to a specific Lark Sheets schema; a tool or framework calling listTables(session, Optional.empty()); catalog-wide metadata scans that ask for all tables across all schemas.

Common situations: Running SHOW TABLES without USE-ing a schema; BI tools that enumerate every table in the catalog at import time; migration/validation scripts iterating the whole catalog.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/eb1da92e351b7c99. Report an issue: GitHub.