{"record":{"id":"f5097c604a6df0a5","repo":"prestodb/presto","slug":"sheets-table-load-error","errorCode":"SHEETS_TABLE_LOAD_ERROR","errorMessage":"Error loading data for table: ","messagePattern":"Error loading data for table: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-google-sheets/src/main/java/com/facebook/presto/google/sheets/SheetsClient.java","lineNumber":157,"sourceCode":"        }\n        catch (UncheckedExecutionException e) {\n            throwIfInstanceOf(e.getCause(), PrestoException.class);\n            throw new PrestoException(SHEETS_METASTORE_ERROR, e);\n        }\n    }\n\n    public List<List<Object>> readAllValues(String tableName)\n    {\n        try {\n            Optional<String> sheetExpression = tableSheetMappingCache.getUnchecked(tableName);\n            if (!sheetExpression.isPresent()) {\n                throw new PrestoException(SHEETS_UNKNOWN_TABLE_ERROR, \"Sheet expression not found for table \" + tableName);\n            }\n            return sheetDataCache.getUnchecked(sheetExpression.get());\n        }\n        catch (UncheckedExecutionException e) {\n            throwIfInstanceOf(e.getCause(), PrestoException.class);\n            throw new PrestoException(SHEETS_TABLE_LOAD_ERROR, \"Error loading data for table: \" + tableName, e);\n        }\n    }\n\n    private Optional<String> getSheetExpressionForTable(String tableName)\n    {\n        Map<String, Optional<String>> tableSheetMap = getAllTableSheetExpressionMapping();\n        if (!tableSheetMap.containsKey(tableName)) {\n            return Optional.empty();\n        }\n        return tableSheetMap.get(tableName);\n    }\n\n    private Map<String, Optional<String>> getAllTableSheetExpressionMapping()\n    {\n        ImmutableMap.Builder<String, Optional<String>> tableSheetMap = ImmutableMap.builder();\n        List<List<Object>> data = readAllValuesFromSheetExpression(metadataSheetId);\n        // first line is assumed to be sheet header\n        for (int i = 1; i < data.size(); i++) {","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-google-sheets/src/main/java/com/facebook/presto/google/sheets/SheetsClient.java#L139-L175","documentation":"SheetsClient.readAllValues wraps any non-Presto failure from the sheet-data cache (UncheckedExecutionException whose cause is not a PrestoException) as SHEETS_TABLE_LOAD_ERROR. It means the table name was known, but actually fetching/reading the sheet data from the Google Sheets API failed.","triggerScenarios":"Google Sheets API errors while loading data: invalid/expired credentials or API key, wrong sheet range/expression, network failures, quota exhaustion, or the spreadsheet deleted/private after mapping.","commonSituations":"Expired or missing OAuth credentials, spreadsheet shared without access for the service account, gid/range in the mapping edited incorrectly, Google API rate limits hit.","solutions":["Check the underlying cause stack trace for the actual Google API error (401/403/404/quota).","Verify sheets credentials configuration (sheets.secrets/credentials) and that the service account still has access to the spreadsheet.","Validate the sheet expression URL/gid in the mapping file is correct and the sheet still exists.","Retry after resolving quota/network issues; reduce refresh frequency if rate-limited."],"exampleFix":"// before (mapping)\n{\"sales\": \"https://docs.google.com/spreadsheets/d/OLDID#gid=99\"} -- deleted gid\n// after\n{\"sales\": \"https://docs.google.com/spreadsheets/d/ACTIVEID#gid=0\"} -- valid, accessible sheet","handlingStrategy":"try-catch","validationCode":"-- verify access outside Presto first\ncurl -H \"Authorization: Bearer $TOKEN\" \"https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/A1:B2\";","typeGuard":null,"tryCatchPattern":"try { return readTable(tableName); } catch (PrestoException e) { if (e.getErrorCode().getName().equals(\"SHEETS_TABLE_LOAD_ERROR\")) { inspectCause(e); // 401/403: fix creds; 403 quota: backoff; 404: fix gid\n return retryWithBackoff(tableName); } throw e; }","preventionTips":["Rotate and test Google API credentials regularly.","Confirm the service account has viewer access to every mapped spreadsheet.","Validate gid/range URLs in the mapping file after sheet edits.","Handle Google API quotas with backoff and caching."],"tags":["google-sheets","connector","api","network"],"backgroundTag":"sheet-data-load-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}