{"record":{"id":"10cbf9ebb00dfa25","repo":"prestodb/presto","slug":"generic-internal-error-10cbf9","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Duplicate column name: ${columnName}","messagePattern":"Duplicate column name: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"critical","filePath":"presto-main-base/src/main/java/com/facebook/presto/connector/system/SystemPageSourceProvider.java","lineNumber":81,"sourceCode":"            ConnectorSplit split,\n            List<ColumnHandle> columns,\n            SplitContext splitContext)\n    {\n        requireNonNull(columns, \"columns is null\");\n        SystemTransactionHandle systemTransaction = (SystemTransactionHandle) transactionHandle;\n        SystemSplit systemSplit = (SystemSplit) split;\n        SchemaTableName tableName = systemSplit.getTableHandle().getSchemaTableName();\n        SystemTable systemTable = tables.getSystemTable(session, tableName)\n                // table might disappear in the meantime\n                .orElseThrow(() -> new PrestoException(NOT_FOUND, format(\"Table %s not found\", tableName)));\n\n        List<ColumnMetadata> tableColumns = systemTable.getTableMetadata().getColumns();\n\n        Map<String, Integer> columnsByName = new HashMap<>();\n        for (int i = 0; i < tableColumns.size(); i++) {\n            ColumnMetadata column = tableColumns.get(i);\n            if (columnsByName.put(column.getName(), i) != null) {\n                throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Duplicate column name: \" + column.getName());\n            }\n        }\n\n        ImmutableList.Builder<Integer> userToSystemFieldIndex = ImmutableList.builder();\n        for (ColumnHandle column : columns) {\n            String columnName = ((SystemColumnHandle) column).getColumnName();\n\n            Integer index = columnsByName.get(columnName);\n            if (index == null) {\n                throw new PrestoException(GENERIC_INTERNAL_ERROR, format(\"Column does not exist: %s.%s\", tableName, columnName));\n            }\n\n            userToSystemFieldIndex.add(index);\n        }\n\n        TupleDomain<ColumnHandle> constraint = systemSplit.getConstraint();\n        ImmutableMap.Builder<Integer, Domain> newConstraints = ImmutableMap.builder();\n        for (Map.Entry<ColumnHandle, Domain> entry : constraint.getDomains().get().entrySet()) {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/connector/system/SystemPageSourceProvider.java#L63-L99","documentation":"While building a column-name-to-index map for a system table, createPageSource detects two ColumnMetadata entries with the same name and throws GENERIC_INTERNAL_ERROR. System tables are required to have unique column names; a duplicate indicates a broken connector/system-table definition, not a user error.","triggerScenarios":"Reading any system table whose getTableMetadata().getColumns() contains a repeated column name (e.g. connector declares columns 'snapshot' and 'snapshot' or duplicates via case-insensitive collision).","commonSituations":"Custom connectors hand-writing SystemTable metadata with copy-pasted column definitions; connectors generating columns dynamically (e.g. per-metric tables) where generated names collide; case-variant names ('Id' vs 'id') colliding in the lowercase map.","solutions":["Fix the connector's SystemTable metadata so every column name is unique and case-insensitively distinct.","For dynamically generated columns, deduplicate names before building ColumnMetadata.","If third-party, upgrade or report the connector; no client-side workaround exists for this internal invariant."],"exampleFix":"// before\ncolumns.add(new ColumnMetadata(\"snapshot\", BIGINT));\ncolumns.add(new ColumnMetadata(\"snapshot\", VARCHAR)); // duplicate\n// after\ncolumns.add(new ColumnMetadata(\"snapshot_count\", BIGINT));\ncolumns.add(new ColumnMetadata(\"snapshot_name\", VARCHAR));","handlingStrategy":"validation","validationCode":"Set<String> seen = new HashSet<>();\nfor (ColumnMetadata c : systemTable.getTableMetadata().getColumns()) {\n    if (!seen.add(c.getName().toLowerCase(Locale.ROOT))) {\n        throw new IllegalStateException(\"Duplicate system table column: \" + c.getName());\n    }\n}","typeGuard":null,"tryCatchPattern":"try { readSystemTable(...); }\ncatch (PrestoException e) { if (e.getErrorCode() == StandardErrorCode.GENERIC_INTERNAL_ERROR.toErrorCode() && e.getMessage().startsWith(\"Duplicate column\")) { reportConnectorBug(); } throw e; }","preventionTips":["Deduplicate generated column names when building SystemTable metadata","Compare names case-insensitively when checking uniqueness","Unit-test custom SystemTables for unique column names"],"tags":["system-tables","schema","connector-bug"],"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"}