{"record":{"id":"45ac19e646329862","repo":"prestodb/presto","slug":"generic-internal-error-45ac19","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"LikePattern type cannot be serialized","messagePattern":"LikePattern type cannot be serialized","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/type/LikePatternType.java","lineNumber":53,"sourceCode":"        super(new TypeSignature(NAME), Regex.class);\n    }\n\n    @Override\n    public Object getObjectValue(SqlFunctionProperties properties, Block block, int position)\n    {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public void appendTo(Block block, int position, BlockBuilder blockBuilder)\n    {\n        throw new UnsupportedOperationException();\n    }\n\n    @Override\n    public BlockBuilder createBlockBuilder(BlockBuilderStatus blockBuilderStatus, int expectedEntries, int expectedBytesPerEntry)\n    {\n        throw new PrestoException(GENERIC_INTERNAL_ERROR, \"LikePattern type cannot be serialized\");\n    }\n\n    @Override\n    public BlockBuilder createBlockBuilder(BlockBuilderStatus blockBuilderStatus, int expectedEntries)\n    {\n        throw new PrestoException(GENERIC_INTERNAL_ERROR, \"LikePattern type cannot be serialized\");\n    }\n}\n","sourceCodeStart":35,"sourceCodeEnd":62,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/type/LikePatternType.java#L35-L62","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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.","Check that LIKE_PATTERN columns never reach serialization points (exchange, spill, output); keep them as transient function arguments only.","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."],"exampleFix":"// before\nType likeType = typeManager.getType(new TypeSignature(LikePatternType.NAME));\nBlockBuilder bb = likeType.createBlockBuilder(new BlockBuilderStatus(), 1);\n// after\n// serialize the pattern as VARCHAR and recompile on the other side\nbb.writeBytes(patternSourceSlice, 0, patternSourceSlice.length()).closeEntry();","handlingStrategy":"type-guard","validationCode":"if (type instanceof LikePatternType) {\n    throw new IllegalStateException(\"LIKE_PATTERN values cannot be written to blocks\");\n}","typeGuard":"boolean isSerializableType(Type t) {\n    return !(t instanceof LikePatternType) && !(t instanceof Re2JRegexpType);\n}","tryCatchPattern":"try {\n    type.createBlockBuilder(status, entries);\n} catch (PrestoException e) {\n    if (GENERIC_INTERNAL_ERROR.equals(e.getErrorCode()) && e.getMessage().contains(\"cannot be serialized\")) {\n        throw new IllegalStateException(\"Do not materialize transient types; pass VARCHAR source instead\", e);\n    }\n    throw e;\n}","preventionTips":["Treat LIKE_PATTERN as a transient scalar-argument-only type; never put it in table schemas or output pages.","When writing generic serialization code, whitelist serializable types instead of assuming all Types work.","Recompile patterns from their VARCHAR source at the point of use rather than shipping compiled objects."],"tags":["presto","serialization","like-pattern","internal-error"],"backgroundTag":"non-serializable-type","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"}