{"record":{"id":"a4adc8a2d73ee814","repo":"prestodb/presto","slug":"generic-internal-error-a4adc8","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Error casting array element to VARCHAR","messagePattern":"Error casting array element to VARCHAR","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/scalar/ArrayJoin.java","lineNumber":340,"sourceCode":"                continue;\n            }\n\n            if (hasOutput) {\n                blockBuilder.writeBytes(delimiter, 0, delimiter.length());\n            }\n\n            if (arrayBlock.isNull(i)) {\n                blockBuilder.writeBytes(nullReplacement, 0, nullReplacement.length());\n            }\n            else {\n                try {\n                    Slice slice = (Slice) castFunction.invokeExact(arrayBlock, i, properties);\n                    blockBuilder.writeBytes(slice, 0, slice.length());\n                }\n                catch (Throwable throwable) {\n                    // Restore blockBuilder into a consistent state\n                    blockBuilder.closeEntry();\n                    throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Error casting array element to VARCHAR\", throwable);\n                }\n            }\n\n            hasOutput = true;\n        }\n\n        blockBuilder.closeEntry();\n    }\n}\n","sourceCodeStart":322,"sourceCodeEnd":350,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/scalar/ArrayJoin.java#L322-L350","documentation":"Runtime failure in ArrayJoin.arrayJoinProvidedBlock: invoking the generated cast of an array element to VARCHAR threw (e.g. an unrepresentable value or a broken cast function); the caught throwable is rewrapped as this cast error while building the joined output string.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/scalar/ArrayJoin.java:340 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pre-cast elements to VARCHAR and handle failures explicitly with TRY_CAST","Replace nulls using array_join's null-replacement argument instead of relying on casts of nulls","Filter out elements that cannot be cast to VARCHAR before joining"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}