prestodb/presto · error · PrestoException
GENERIC_INTERNAL_ERROR
GENERIC_INTERNAL_ERROR
Error message
RegExp type cannot be serialized
What it means
Re2JRegexpType wraps compiled RE2/J Pattern objects used by regexp functions. Like LikePatternType, compiled regex objects are transient engine values that cannot be materialized into a Block, so createBlockBuilder(status, expectedEntries, expectedBytesPerEntry) unconditionally throws GENERIC_INTERNAL_ERROR 'RegExp type cannot be serialized'.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/type/Re2JRegexpType.java:52
super(new TypeSignature(NAME), Re2JRegexp.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, "RegExp type cannot be serialized");
}
@Override
public BlockBuilder createBlockBuilder(BlockBuilderStatus blockBuilderStatus, int expectedEntries)
{
throw new PrestoException(GENERIC_INTERNAL_ERROR, "RegExp type cannot be serialized");
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Carry patterns as VARCHAR and compile them with re2jPattern(VARCHAR) at the point of use instead of serializing the compiled object.
- Ensure REGEXP-typed values never reach exchange/spill/output paths; keep them as scalar function arguments only.
- Add an instanceof Re2JRegexpType guard in generic block-building/serialization code to route to a non-materializing path.
Example fix
// before BlockBuilder bb = re2jRegexpType.createBlockBuilder(new BlockBuilderStatus(), 1, 32); // after bb.writeBytes(patternSourceSlice, 0, patternSourceSlice.length()).closeEntry(); // send VARCHAR, recompile later
Defensive patterns
Strategy: type-guard
Validate before calling
if (type instanceof Re2JRegexpType) {
throw new IllegalStateException("RegExp values cannot be written to blocks");
} Type guard
boolean isSerializableType(Type t) {
return !(t instanceof Re2JRegexpType) && !(t instanceof LikePatternType);
} Try / catch
try {
bb = type.createBlockBuilder(status, entries, bytesPerEntry);
} catch (PrestoException e) {
if (e.getMessage().contains("RegExp type cannot be serialized")) {
throw new IllegalStateException("Pass the pattern as VARCHAR and recompile with re2jPattern()", e);
}
throw e;
} Prevention
- Never declare REGEXP-typed columns in tables, outputs, or aggregation inputs; it is a transient function-argument type.
- In generic connectors, check for transient types before calling createBlockBuilder.
- Serialize the pattern source string, not the compiled Re2J Pattern.
When it happens
Trigger: Calling Re2JRegexpType.createBlockBuilder(BlockBuilderStatus, int, int) — any attempt to write RE2J_REGEXP values into a page for exchange, aggregation, output, or in engine/plugin code that generically serializes all column types.
Common situations: Custom connectors or functions that try to return/store a REGEXP-typed column; misuse of the transient REGEXP type in a table schema; engine changes that route compiled patterns through serialization points.
Related errors
- GENERIC_INTERNAL_ERROR
- GENERIC_INTERNAL_ERROR
- GENERIC_INTERNAL_ERROR
- GENERIC_INTERNAL_ERROR
- INVALID_FUNCTION_ARGUMENT
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/0b64915c7300c82e.
Report an issue: GitHub.