prestodb/presto · error · PrestoException

GENERIC_INTERNAL_ERROR

GENERIC_INTERNAL_ERROR

Error message

LikePattern type cannot be serialized

What it means

LikePatternType represents compiled LIKE pattern values (from PREPARE-like internal LIKE handling) in Presto. These values only exist transiently in the engine and are not designed to be materialized into a Block for serialization, exchange, or storage. Any attempt to create a block builder for this type immediately fails with GENERIC_INTERNAL_ERROR, signaling an engine-level misuse rather than a user-facing SQL problem.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/type/LikePatternType.java:53

        super(new TypeSignature(NAME), Regex.class);
    }

    @Override
    public Object getObjectValue(SqlFunctionProperties properties, Block block, int position)
    {
        throw new UnsupportedOperationException();
    }

    @Override
    public void appendTo(Block block, int position, BlockBuilder blockBuilder)
    {
        throw new UnsupportedOperationException();
    }

    @Override
    public BlockBuilder createBlockBuilder(BlockBuilderStatus blockBuilderStatus, int expectedEntries, int expectedBytesPerEntry)
    {
        throw new PrestoException(GENERIC_INTERNAL_ERROR, "LikePattern type cannot be serialized");
    }

    @Override
    public BlockBuilder createBlockBuilder(BlockBuilderStatus blockBuilderStatus, int expectedEntries)
    {
        throw new PrestoException(GENERIC_INTERNAL_ERROR, "LikePattern type cannot be serialized");
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Do not serialize LikePattern values: restructure the operator/plugin so the pattern is recompiled (via LikeFunctions.likePattern) from its VARCHAR source on the receiving side instead of shipping the object.
  2. Check that LIKE_PATTERN columns never reach serialization points (exchange, spill, output); keep them as transient function arguments only.
  3. If writing a custom function, avoid declaring LIKE_PATTERN parameters/returns unless it is a scalar function handled by the compiler; use VARCHAR plus a like function instead.

Example fix

// before
Type likeType = typeManager.getType(new TypeSignature(LikePatternType.NAME));
BlockBuilder bb = likeType.createBlockBuilder(new BlockBuilderStatus(), 1);
// after
// serialize the pattern as VARCHAR and recompile on the other side
bb.writeBytes(patternSourceSlice, 0, patternSourceSlice.length()).closeEntry();
Defensive patterns

Strategy: type-guard

Validate before calling

if (type instanceof LikePatternType) {
    throw new IllegalStateException("LIKE_PATTERN values cannot be written to blocks");
}

Type guard

boolean isSerializableType(Type t) {
    return !(t instanceof LikePatternType) && !(t instanceof Re2JRegexpType);
}

Try / catch

try {
    type.createBlockBuilder(status, entries);
} catch (PrestoException e) {
    if (GENERIC_INTERNAL_ERROR.equals(e.getErrorCode()) && e.getMessage().contains("cannot be serialized")) {
        throw new IllegalStateException("Do not materialize transient types; pass VARCHAR source instead", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling LikePatternType.createBlockBuilder(status, expectedEntries) or createBlockBuilder(status, expectedEntries, expectedBytesPerEntry) — i.e., any code path that tries to buffer or serialize LIKE_PATTERN values into a Block (e.g., writing them through an exchange, aggregation, or output sink).

Common situations: Custom connectors/plugins that assume every type is serializable and blindly call createBlockBuilder; engine changes that accidentally route LikePattern values through operators that materialize input columns; attempts to use LIKE_PATTERN as a column/return type in a custom function.

Related errors


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