{"record":{"id":"f4b9176de677d273","repo":"prestodb/presto","slug":"escape-not-implemented","errorCode":null,"errorMessage":"escape not implemented","messagePattern":"escape not implemented","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-rcfile/src/main/java/com/facebook/presto/rcfile/text/StringEncoding.java","lineNumber":51,"sourceCode":"\n    public StringEncoding(Type type, Slice nullSequence, Byte escapeChar)\n    {\n        this.type = type;\n        this.nullSequence = nullSequence;\n        this.escapeByte = escapeChar;\n    }\n\n    @Override\n    public void encodeColumn(Block block, SliceOutput output, EncodeOutput encodeOutput)\n    {\n        for (int position = 0; position < block.getPositionCount(); position++) {\n            if (block.isNull(position)) {\n                output.writeBytes(nullSequence);\n            }\n            else {\n                Slice slice = type.getSlice(block, position);\n                if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) {\n                    throw new IllegalArgumentException(\"escape not implemented\");\n                }\n                output.writeBytes(slice);\n            }\n            encodeOutput.closeEntry();\n        }\n    }\n\n    @Override\n    public void encodeValueInto(int depth, Block block, int position, SliceOutput output)\n    {\n        Slice slice = type.getSlice(block, position);\n        if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) {\n            throw new IllegalArgumentException(\"escape not implemented\");\n        }\n        output.writeBytes(slice);\n    }\n\n    @Override","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-rcfile/src/main/java/com/facebook/presto/rcfile/text/StringEncoding.java#L33-L69","documentation":"Text StringEncoding writes values verbatim and only knows how to handle the field delimiter; if an escape byte is configured and the value contains the escape character, escaping is not implemented, so encodeColumn throws IllegalArgumentException rather than producing ambiguous output.","triggerScenarios":"encodeColumn on a VARCHAR column where escapeByte != null and the slice contains that escape byte — e.g. writing data containing '\\' (or the configured escape) to a text RCFile with escaping enabled.","commonSituations":"Tables defined with an escape character (like TSV/CSV-style escaping) receiving user data containing that character; ETL jobs migrating free-text data into escaped RCFile tables.","solutions":["Remove the escape character from the table definition (use a format without escaping)","Pre-process data to strip or replace occurrences of the escape byte before writing","Switch the table to ORC/Parquet or a text format with proper escape support","Catch IllegalArgumentException and reject/sanitize the offending rows"],"exampleFix":"// before\nCREATE TABLE t (s varchar) WITH (format='RCFILE', text_escape='\\\\');\n// after\nCREATE TABLE t (s varchar) WITH (format='RCFILE'); -- escape removed, or sanitize s first","handlingStrategy":"validation","validationCode":"// before writing a varchar column when escape is configured\nSlice slice = type.getSlice(block, position);\nif (escapeByte != null && slice.indexOfByte(escapeByte) >= 0) {\n    // sanitize: strip/replace escape byte, or choose a different format\n    slice = replaceByte(slice, escapeByte, (byte) ' ');\n}","typeGuard":null,"tryCatchPattern":"try { stringEncoding.encodeColumn(block, output, encodeOutput); }\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"escape not implemented\")) {\n        encodeColumn(sanitize(block, escapeByte), output, encodeOutput); // strip escape and retry\n    } else { throw e; }\n}","preventionTips":["Avoid configuring escape characters on RCFile text tables containing free text","Strip or escape-encode values in ETL before writing","Use ORC/Parquet for arbitrary text data","Document table escape settings so writers know the constraint"],"tags":["rcfile","text-encoding","escape","writer"],"backgroundTag":"escape-character-unsupported","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"}