prestodb/presto · error · IllegalArgumentException

escape not implemented

Error message

escape not implemented

What it means

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.

Solutions

  1. Remove the escape character from the table definition (use a format without escaping)
  2. Pre-process data to strip or replace occurrences of the escape byte before writing
  3. Switch the table to ORC/Parquet or a text format with proper escape support
  4. Catch IllegalArgumentException and reject/sanitize the offending rows

Example fix

// before
CREATE TABLE t (s varchar) WITH (format='RCFILE', text_escape='\\');
// after
CREATE TABLE t (s varchar) WITH (format='RCFILE'); -- escape removed, or sanitize s first
Defensive patterns

Strategy: validation

Validate before calling

// before writing a varchar column when escape is configured
Slice slice = type.getSlice(block, position);
if (escapeByte != null && slice.indexOfByte(escapeByte) >= 0) {
    // sanitize: strip/replace escape byte, or choose a different format
    slice = replaceByte(slice, escapeByte, (byte) ' ');
}

Try / catch

try { stringEncoding.encodeColumn(block, output, encodeOutput); }
catch (IllegalArgumentException e) {
    if (e.getMessage().equals("escape not implemented")) {
        encodeColumn(sanitize(block, escapeByte), output, encodeOutput); // strip escape and retry
    } else { throw e; }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/f4b9176de677d273. Report an issue: GitHub.

Appendix: source

Thrown at presto-rcfile/src/main/java/com/facebook/presto/rcfile/text/StringEncoding.java:51

    public StringEncoding(Type type, Slice nullSequence, Byte escapeChar)
    {
        this.type = type;
        this.nullSequence = nullSequence;
        this.escapeByte = escapeChar;
    }

    @Override
    public void encodeColumn(Block block, SliceOutput output, EncodeOutput encodeOutput)
    {
        for (int position = 0; position < block.getPositionCount(); position++) {
            if (block.isNull(position)) {
                output.writeBytes(nullSequence);
            }
            else {
                Slice slice = type.getSlice(block, position);
                if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) {
                    throw new IllegalArgumentException("escape not implemented");
                }
                output.writeBytes(slice);
            }
            encodeOutput.closeEntry();
        }
    }

    @Override
    public void encodeValueInto(int depth, Block block, int position, SliceOutput output)
    {
        Slice slice = type.getSlice(block, position);
        if (escapeByte != null && slice.indexOfByte(escapeByte) < 0) {
            throw new IllegalArgumentException("escape not implemented");
        }
        output.writeBytes(slice);
    }

    @Override

View on GitHub (pinned to 55bb57d202)