{"record":{"id":"cd4f4e66c0bb6263","repo":"prestodb/presto","slug":"decoder-conversion-not-supported-cd4f4e","errorCode":"DECODER_CONVERSION_NOT_SUPPORTED","errorMessage":"cannot decode object of '%s' as '%s' for column '%s'","messagePattern":"cannot decode object of '(.+?)' as '(.+?)' for column '(.+?)'","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-record-decoder/src/main/java/com/facebook/presto/decoder/avro/AvroColumnDecoder.java","lineNumber":168,"sourceCode":"        {\n            this.value = value;\n            this.columnType = columnType;\n            this.columnName = columnName;\n        }\n\n        @Override\n        public boolean isNull()\n        {\n            return value == null;\n        }\n\n        @Override\n        public double getDouble()\n        {\n            if (value instanceof Double || value instanceof Float) {\n                return ((Number) value).doubleValue();\n            }\n            throw new PrestoException(DECODER_CONVERSION_NOT_SUPPORTED, format(\"cannot decode object of '%s' as '%s' for column '%s'\", value.getClass(), columnType, columnName));\n        }\n\n        @Override\n        public boolean getBoolean()\n        {\n            if (value instanceof Boolean) {\n                return (Boolean) value;\n            }\n            throw new PrestoException(DECODER_CONVERSION_NOT_SUPPORTED, format(\"cannot decode object of '%s' as '%s' for column '%s'\", value.getClass(), columnType, columnName));\n        }\n\n        @Override\n        public long getLong()\n        {\n            if (value instanceof Long || value instanceof Integer) {\n                return ((Number) value).longValue();\n            }\n            throw new PrestoException(DECODER_CONVERSION_NOT_SUPPORTED, format(\"cannot decode object of '%s' as '%s' for column '%s'\", value.getClass(), columnType, columnName));","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-record-decoder/src/main/java/com/facebook/presto/decoder/avro/AvroColumnDecoder.java#L150-L186","documentation":"Presto's Avro record decoder throws DECODER_CONVERSION_NOT_SUPPORTED when an Avro field value cannot be converted to the declared Presto column type. The getDouble() accessor only accepts Avro values that are Double or Float; anything else (e.g. String, Integer, GenericRecord) is rejected. This signals a mismatch between the Avro schema/actual record data and the Presto table column type mapping.","triggerScenarios":"Decoding an Avro record whose field value is not Double/Float while the mapped column requires double (e.g. DOUBLE-typed column whose Avro field is a string or int).","commonSituations":"Table column declared DOUBLE in Presto but the Avro schema field is int/long/string; schema evolution changed the field type; wrong Avro schema supplied in the Kafka topic decoder config so values deserialize as Strings or GenericFixed.","solutions":["Change the Presto column type (or the Avro field mapping) to match the actual Avro field type, e.g. use BIGINT/INTEGER for int/long fields","Ensure the correct writer/reader Avro schema is configured so the field deserializes as float/double","Add an explicit conversion in the decoder (custom decoder or view with CAST) instead of relying on implicit coercion"],"exampleFix":"// before (Presto column: DOUBLE, Avro field: \"int\")\nCREATE TABLE t (metric DOUBLE) ...;\n// after\nCREATE TABLE t (metric BIGINT) ...; -- matches Avro int/long field","handlingStrategy":"type-guard","validationCode":"// Validate Avro schema field types against expected Presto column types before creating/decoding\nSchema.Field field = schema.getField(columnName);\nif (field.schema().getType() != Schema.Type.DOUBLE && field.schema().getType() != Schema.Type.FLOAT) {\n    throw new IllegalArgumentException(\"Column '\" + columnName + \"' expects a double/float Avro field\");\n}","typeGuard":"boolean isDecodableAsDouble(Object avroValue) {\n    return avroValue instanceof Double || avroValue instanceof Float;\n}","tryCatchPattern":"try {\n    double d = block.getDouble(field);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getName().contains(\"DECODER_CONVERSION_NOT_SUPPORTED\")) {\n        // fall back to reading as string / log schema mismatch\n    } else {\n        throw e;\n    }\n}","preventionTips":["Keep the Presto table column types in sync with the Avro schema field types","Validate the Avro schema (e.g. with avro-tools or a schema registry check) before creating the table","Enable schema-compatibility checks in the registry so field types cannot change incompatibly","Re-run column mapping generation whenever the Avro schema evolves"],"tags":["avro","decoder","type-mismatch","presto"],"backgroundTag":"decoder-conversion-not-supported","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"}