prestodb/presto · error · PrestoException
SHEET_NAME_AMBIGUOUS
SHEET_NAME_AMBIGUOUS
Error message
Ambiguous name %s in spreadsheet %s: matched sheets: %s
What it means
LarkSheetsMetadata.getTableHandle resolves a user-supplied sheet/table name against the sheets of a Lark spreadsheet identified by token. filterSheets does a name match; if more than one sheet matches, the connector refuses to guess and throws LarkSheetsErrorCode.SHEET_NAME_AMBIGUOUS with the list of matched sheets. The token is masked in the message for security.
Source
Thrown at presto-lark-sheets/src/main/java/com/facebook/presto/lark/sheets/LarkSheetsMetadata.java:107
return getVisibleSchema(session, schemaName).isPresent();
}
@Nullable
@Override
public ConnectorTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName)
{
String schemaName = tableName.getSchemaName();
LarkSheetsSchema schema = requireVisibleSchema(session, schemaName);
checkSchemaReadable(schema);
String token = schema.getToken();
String sheetName = tableName.getTableName();
SpreadsheetInfo spreadsheetInfo = api.getMetaInfo(token);
List<SheetInfo> matched = filterSheets(spreadsheetInfo.getSheets(), sheetName);
if (matched.isEmpty()) {
return null;
}
else if (matched.size() > 1) {
throw new PrestoException(LarkSheetsErrorCode.SHEET_NAME_AMBIGUOUS,
format("Ambiguous name %s in spreadsheet %s: matched sheets: %s", sheetName, mask(token), matched));
}
SheetInfo sheet = matched.get(0);
return toSheetsTableHandle(sheet);
}
@Override
public Optional<SystemTable> getSystemTable(ConnectorSession session, SchemaTableName tableName)
{
String schemaName = tableName.getSchemaName();
LarkSheetsSchema schema = requireVisibleSchema(session, schemaName);
checkSchemaReadable(schema);
if (LarkSheetsSystemTable.requestsSheets(tableName.getTableName())) {
SpreadsheetInfo metaInfo = api.getMetaInfo(schema.getToken());
return Optional.of(new LarkSheetsSystemTable(schema.getName(), metaInfo.getSheets()));
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Rename the duplicate sheets in the Lark spreadsheet so exactly one sheet matches the requested name.
- Reference the sheet unambiguously in the query using the exact, unique sheet name.
- Delete the redundant sheet copy that collides with the original.
- Query the metadata (information_schema.tables) to list actual sheet names and pick the right one.
Example fix
// before SELECT * FROM lark_sheets."docToken".sales; -- matches 'Sales' and 'sales' // after: rename one sheet in Lark, then SELECT * FROM lark_sheets."docToken".sales; -- now matches exactly one sheet
Defensive patterns
Strategy: validation
Validate before calling
List<String> tables = execute("SHOW TABLES FROM lark_sheets.my_schema").column("name");
String wanted = "sales";
long matches = tables.stream().filter(t -> t.equalsIgnoreCase(wanted)).count();
if (matches != 1) { throw new IllegalStateException("sheet 'sales' matches " + matches + " sheets; rename duplicates in Lark"); } Try / catch
try { return metadata.getTableHandle(session, tableName); } catch (PrestoException e) { if (e.getErrorCode().getCode() == LarkSheetsErrorCode.SHEET_NAME_AMBIGUOUS.toErrorCode().getCode()) { // pick exact-case name or ask user to rename sheets } else { throw e; } } Prevention
- Enforce unique, case-distinct sheet names in shared spreadsheets
- Avoid copy/sheet-duplication without renaming
- List tables (SHOW TABLES) before referencing by name
- Use the exact name returned by metadata, not a prefix
When it happens
Trigger: CallinggetTableHandle (i.e. querying a named table in the spreadsheet schema) where case-insensitive/filtered sheet-name matching returns 2+ SheetInfo entries, e.g. duplicate sheet names or names differing only in case in the same spreadsheet.
Common situations: A Lark spreadsheet has two sheets named 'Sales' and 'sales'; a rename left a stale duplicate sheet; the sheetName filter uses a substring/prefix that matches multiple sheets; collaborators copied a sheet without renaming it.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/3efcadb6e4f50ff5.
Report an issue: GitHub.