{"record":{"id":"81232c9f03da312f","repo":"prestodb/presto","slug":"kdbtree-type-cannot-be-serialized","errorCode":null,"errorMessage":"KdbTree type cannot be serialized","messagePattern":"KdbTree type cannot be serialized","errorType":"exception","errorClass":"GenericInternalException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/type/KdbTreeType.java","lineNumber":48,"sourceCode":"        super(new TypeSignature(NAME), Object.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 GenericInternalException(\"KdbTree type cannot be serialized\");\n    }\n\n    @Override\n    public BlockBuilder createBlockBuilder(BlockBuilderStatus blockBuilderStatus, int expectedEntries)\n    {\n        throw new GenericInternalException(\"KdbTree type cannot be serialized\");\n    }\n}\n","sourceCodeStart":30,"sourceCodeEnd":57,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/type/KdbTreeType.java#L30-L57","documentation":"KdbTreeType represents the KDB tree hyperloglog-like structure used in approximate set building. KdbTree values live only inside the engine as object representations and have no block/serialization representation, so createBlockBuilder throws GenericInternalException(\"KdbTree type cannot be serialized\") to fail fast if anyone tries to write a KdbTree into a Block. It signals a misuse of the type rather than corrupt data.","triggerScenarios":"Calling KdbTreeType.createBlockBuilder(status, expectedEntries) (or the expectedEntries+expectedBytesPerEntry overload, error 441) — e.g. writing a KdbTree value into a page builder or trying to persist/cast a KdbTree column.","commonSituations":"Attempts to serialize a state_merge/setdigest output column to storage, spill, or exchange; custom connectors/operators treating KdbTree as an ordinary scalar; casting or outputting setdigest columns to text/block form.","solutions":["Do not write KdbTree values into Blocks; KdbTree is only for in-engine state — stop serializing that column.","Use the intended intermediate type (e.g. setdigest via varbinary digest form) if you need to persist approximate-set state.","If you need to materialize results, extract aggregates from the KdbTree via the appropriate UDFs instead of serializing the tree itself."],"exampleFix":"// before: pageBuilder writing kdbTree value via its type\nkdbTreeType.writeLong(blockBuilder, tree)\n// after: avoid serializing; extract or use setdigest varbinary\nblockBuilder.writeBytes(setDigestVarbinary).closeEntry()","handlingStrategy":"type-guard","validationCode":"if (type instanceof KdbTreeType) { throw new IllegalStateException(\"KdbTree columns cannot be serialized\"); }","typeGuard":"boolean isSerializableType(Type t) { return !(t instanceof KdbTreeType); }","tryCatchPattern":"try { type.createBlockBuilder(status, entries); } catch (GenericInternalException e) { /* fall back to non-serialized representation */ }","preventionTips":["Never include setdigest/KdbTree columns in materialized output, spill, or exchange paths.","Check type instanceof KdbTreeType before generic block-building loops.","Use varbinary digest representations for persisting approximate-set state."],"tags":["serialization","internal-error","unsupported-operation"],"backgroundTag":"type-not-serializable","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"}