{"record":{"id":"5a11e7c7b1691fd1","repo":"prestodb/presto","slug":"sheet-invalid-header","errorCode":"SHEET_INVALID_HEADER","errorMessage":"Duplicated name %s in Column#%s and Column#%s","messagePattern":"Duplicated name (.+?) in Column#(.+?) and Column#(.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-lark-sheets/src/main/java/com/facebook/presto/lark/sheets/LarkSheetsMetadata.java","lineNumber":295,"sourceCode":"\n    private List<LarkSheetsColumnHandle> getColumns(LarkSheetsTableHandle table)\n    {\n        List<String> header = api.getHeaderRow(table.getSpreadsheetToken(), table.getSheetId(), table.getColumnCount());\n\n        int numColumns = header.size();\n        LinkedHashMap<String, LarkSheetsColumnHandle> columns = new LinkedHashMap<>(numColumns);\n        for (int i = 0; i < numColumns; i++) {\n            String rawColumnName = header.get(i);\n            if (rawColumnName == null) {\n                // Columns without name are ignored\n                continue;\n            }\n            String columnName = rawColumnName.toLowerCase(ENGLISH);\n            LarkSheetsColumnHandle column = columns.get(columnName);\n            if (column != null) {\n                String label = LarkSheetsUtil.columnIndexToColumnLabel(i);\n                String prevLabel = LarkSheetsUtil.columnIndexToColumnLabel(column.getIndex());\n                throw new PrestoException(SHEET_INVALID_HEADER,\n                        format(\"Duplicated name %s in Column#%s and Column#%s\", columnName, prevLabel, label));\n            }\n            columns.put(columnName, new LarkSheetsColumnHandle(columnName, VARCHAR, i));\n        }\n        return ImmutableList.copyOf(columns.values());\n    }\n\n    private static List<SheetInfo> filterSheets(List<SheetInfo> sheets, String filter)\n    {\n        requireNonNull(sheets, \"sheets is null\");\n        checkArgument(!isNullOrEmpty(filter), \"filter is null or empty\");\n\n        char firstChar = filter.charAt(0);\n        if (firstChar == '$') {\n            // filter by index\n            Matcher matcher = INDEX_PATTERN.matcher(filter);\n            if (matcher.matches()) {\n                int i = Integer.parseInt(filter.substring(1));","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-lark-sheets/src/main/java/com/facebook/presto/lark/sheets/LarkSheetsMetadata.java#L277-L313","documentation":"getColumns reads the spreadsheet's header row and lowercases each column name to build column handles. If two header cells yield the same lowercase name, a later duplicate would overwrite the earlier mapping, so the connector detects the collision and throws SHEET_INVALID_HEADER, reporting the duplicated name and the two column labels (A, B, C, ...) where it occurred.","triggerScenarios":"Sheet header row contains two cells whose lowercase forms are equal (e.g. 'Name' in column A and 'name' in column C, or exact duplicates), detected while building column handles for a table.","commonSituations":"Spreadsheet edited by multiple people who added near-duplicate headers ('Email', 'email'); trailing spaces or case differences that collapse after lowercasing; imported CSV headers with repeated fields.","solutions":["Rename one of the duplicate header cells in the Lark sheet so all headers are unique after lowercasing.","Trim whitespace and check case-only differences ('Name' vs 'name') in the header row.","Restructure the sheet so each column has a distinct header name.","If it must stay, split into two sheets and reference the one with clean headers."],"exampleFix":"// header row before: A='Name', B='Age', C='name'\n// after\n// header row: A='Name', B='Age', C='Nickname'","handlingStrategy":"validation","validationCode":"Set<String> seen = new HashSet<>();\nfor (String header : headerRow) {\n    String k = header.trim().toLowerCase(Locale.ROOT);\n    if (!seen.add(k)) throw new IllegalStateException(\"Duplicate header after normalization: \" + k);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep header rows unique ignoring case and whitespace","Audit headers after collaborative edits","Trim and normalize headers when authoring sheets","Run a pre-query header check via DESCRIBE in CI"],"tags":["presto-connector","lark-sheets","schema-validation","headers"],"backgroundTag":"duplicate-column-name","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"}