{"record":{"id":"c3b7d1d8d618d567","repo":"prestodb/presto","slug":"invalid-mapping-s-for-column-s","errorCode":null,"errorMessage":"invalid mapping '%s' for column '%s'","messagePattern":"invalid mapping '(.+?)' for column '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-record-decoder/src/main/java/com/facebook/presto/decoder/csv/CsvColumnDecoder.java","lineNumber":60,"sourceCode":"    private final Type columnType;\n    private final int columnIndex;\n\n    public CsvColumnDecoder(DecoderColumnHandle columnHandle)\n    {\n        try {\n            requireNonNull(columnHandle, \"columnHandle is null\");\n            checkArgument(!columnHandle.isInternal(), \"unexpected internal column '%s'\", columnHandle.getName());\n            columnName = columnHandle.getName();\n            checkArgument(columnHandle.getFormatHint() == null, \"unexpected format hint '%s' defined for column '%s'\", columnHandle.getFormatHint(), columnName);\n            checkArgument(columnHandle.getDataFormat() == null, \"unexpected data format '%s' defined for column '%s'\", columnHandle.getDataFormat(), columnName);\n            columnType = columnHandle.getType();\n\n            checkArgument(columnHandle.getMapping() != null, \"mapping not defined for column '%s'\", columnName);\n            try {\n                columnIndex = Integer.parseInt(columnHandle.getMapping());\n            }\n            catch (NumberFormatException e) {\n                throw new IllegalArgumentException(format(\"invalid mapping '%s' for column '%s'\", columnHandle.getMapping(), columnName));\n            }\n            checkArgument(columnIndex >= 0, \"invalid mapping '%s' for column '%s'\", columnHandle.getMapping(), columnName);\n\n            checkArgument(isSupportedType(columnType), \"Unsupported column type '%s' for column '%s'\", columnType.getDisplayName(), columnName);\n        }\n        catch (IllegalArgumentException e) {\n            throw new PrestoException(GENERIC_USER_ERROR, e);\n        }\n    }\n\n    private static boolean isSupportedType(Type type)\n    {\n        if (isVarcharType(type)) {\n            return true;\n        }\n        if (ImmutableList.of(BIGINT, INTEGER, SMALLINT, TINYINT, BOOLEAN, DOUBLE).contains(type)) {\n            return true;\n        }","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-record-decoder/src/main/java/com/facebook/presto/decoder/csv/CsvColumnDecoder.java#L42-L78","documentation":"During CsvColumnDecoder construction, each column's mapping string must parse to a non-negative integer CSV field index. If Integer.parseInt fails (non-numeric mapping) or the parsed index is negative, the constructor throws IllegalArgumentException with this message. It is a table/connector configuration error caught at decoder build time, not a data error.","triggerScenarios":"Column mapping in the connector config is a non-numeric string (e.g. 'name', '1a'); mapping is negative (e.g. '-1'); mapping property missing but the null check above passed only for other columns.","commonSituations":"Typos in CREATE TABLE mapping syntax; copying JSON decoder configs (which use JSON paths) into a CSV table; template scripts substituting placeholders like '{idx}' that never got replaced; off-by-one attempts using negative indexes.","solutions":["Set the column mapping to a zero-based integer matching the CSV field position, e.g. mapping='3'","Validate all column mappings are numeric and >= 0 before running the query","Check the connector-specific documentation for the mapping syntax (CSV requires integer indexes, not field names)","Fix the table definition (CREATE TABLE ... COMMENT with mappings) and recreate/alter the table"],"exampleFix":"// before\n{\"name\": \"user_id\", \"mapping\": \"userId\"}\n// after\n{\"name\": \"user_id\", \"mapping\": \"0\"}","handlingStrategy":"validation","validationCode":"void validateCsvMappings(Map<String,String> mappings) {\n    mappings.forEach((col, m) -> {\n        if (m == null) throw new IllegalArgumentException(\"mapping not defined for column '\" + col + \"'\");\n        int idx;\n        try { idx = Integer.parseInt(m.trim()); }\n        catch (NumberFormatException e) { throw new IllegalArgumentException(\"invalid mapping '\" + m + \"' for column '\" + col + \"'\"); }\n        if (idx < 0) throw new IllegalArgumentException(\"invalid mapping '\" + m + \"' for column '\" + col + \"'\");\n    });\n}","typeGuard":null,"tryCatchPattern":"try {\n    CsvColumnDecoder d = new CsvColumnDecoder(columnHandles);\n} catch (IllegalArgumentException e) {\n    throw new TableConfigException(\"Fix column mappings in table definition: \" + e.getMessage(), e);\n}","preventionTips":["Use only zero-based integers in CSV column mappings","Validate mappings in CI against a sample CSV header","Never reuse JSON-path mappings for CSV tables"],"tags":["csv","configuration","decoding","table-definition"],"backgroundTag":"invalid-column-mapping","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"}